严重: Exception sending context...Caused by: org.springframework.beans.factory.BeanCreationException: [applicationContext.xml]: Error setting property values;

HTTP Status 500 - Unable to instantiate Action, userAction, defined for 'UserAction_login' in namespace '/'Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.web.action.UserAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


type Exception report

message Unable to instantiate Action, userAction, defined for 'UserAction_login' in namespace '/'Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.web.action.UserAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

description The server encountered an internal error that prevented it from fulfilling this request.

exception

Unable to instantiate Action, userAction,  defined for 'UserAction_login' in namespace '/'Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.web.action.UserAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? - action - file:/D:/ProgramData/apache-tomcat-7.0.52/webapps/ssh_crm/WEB-INF/classes/struts.xml:23:64
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:314)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:395)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	org.springframework.orm.hibernate5.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.web.action.UserAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1518)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
	com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:161)
	com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:178)
	com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22)
	com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:148)
	com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:295)
	com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:395)
	com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
	org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
	org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
	com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
	org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:554)
	org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
	org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	org.springframework.orm.hibernate5.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

root causeorg.springframework.beans.NotWritablePropertyException: Invalid property 'userService' of bean class [cn.itcast.web.action.UserAction]: Bean property 'userService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:231)

	...
错误原因:
Bean类[cn.itcast.web.action.UserAction]属性'userService'是无效的setter方法,写错了。
改为正确的:

public void setUserService(UserService userService) {
  this.userService = userService;
}

猜你喜欢

转载自www.cnblogs.com/mingyangli/p/12452525.html