java创建bean Unable to instantiate Action

J2EE 码拜 9年前 (2015-07-11) 2584次浏览 0个评论

异常提示如下:
2015-06-24 11:06:34,470 [http-apr-8087-exec-4] ERROR org.apache.struts2.dispatcher.Dispatcher – Exception occurred during processing request: Unable to instantiate Action, hospitalAction, defined for “”hospinfo_getDistricInfo”” in namespace “”/””Error creating bean with name “”hospitalAction”” defined in class path resource [springConfig/action-beans.xml]: Cannot resolve reference to bean “”tPortalMtHosplInfoIService”” while setting bean property “”tPortalMtHosplInfoIService””; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named “”tPortalMtHosplInfoIService”” is defined
Unable to instantiate Action, hospitalAction, defined for “”hospinfo_getDistricInfo”” in namespace “”/””Error creating bean with name “”hospitalAction”” defined in class path resource [springConfig/action-beans.xml]: Cannot resolve reference to bean “”tPortalMtHosplInfoIService”” while setting bean property “”tPortalMtHosplInfoIService””; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named “”tPortalMtHosplInfoIService”” is defined
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397)
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name “”hospitalAction”” defined in class path resource [springConfig/action-beans.xml]: Cannot resolve reference to bean “”tPortalMtHosplInfoIService”” while setting bean property “”tPortalMtHosplInfoIService””; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named “”tPortalMtHosplInfoIService”” is defined
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:283)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:151)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:171)
at com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22)
at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:297)
… 24 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named “”tPortalMtHosplInfoIService”” is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:971)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
… 40 more
提示是无法初始化action。
其中””tPortalMtHosplInfoIService”” 在service-beans.xml定义了,定义如下:<bean id=”tPortalMtHosplInfoIDAO” class=”gdcc.hsps.server.portal.reginfo.mt.TPortalMtHosplInfoIDAOImpl” parent=”sessionTemplate”></bean>
<bean id=”tPortalMtHosplInfoIService” class=”gdcc.hsps.server.portal.reginfo.mt.TPortalMtHosplInfoIServiceImpl”>
<property name=”tPortalMtHosplInfoIDAO” ref=”tPortalMtHosplInfoIDAO”></property>
</bean>
<bean id=”TPortalMtHosplInfo” class=”transactionBase”>
<property name=”target” ref=”tPortalMtHosplInfoIDAO”></property>
</bean>
action的定义在action-beans.xml文件。定义如下:<bean id=”hospitalAction” class=”gdcc.hsps.web.actions.reginfo.mt.HospitalInfoAction” scope=”prototype”>
<property name=”tPortalMtHosplInfoIService” ref=”tPortalMtHosplInfoIService”></property>
<property name=”tPortalMtDistrictIService” ref=”tPortalMtDistrictIService”></property>
</bean>

5分

你这格式太乱了,调整一下代码格式,否则谁愿意看又长又没格式的代码啊

30分

楼主:
1、请检查:<property name=”tPortalMtHosplInfoIService” ref=”tPortalMtHosplInfoIService”></property>对应的

<bean id="tPortalMtHosplInfoIService" class="gdcc.hsps.server.portal.reginfo.mt.TPortalMtHosplInfoIServiceImpl">
	<property name="tPortalMtHosplInfoIDAO" ref="tPortalMtHosplInfoIDAO"></property>
</bean>

是否正确。
2、从你的xml配置中,我并未看到:

<property name="tPortalMtDistrictIService" ref="tPortalMtDistrictIService"></property>

的注解。
3、请你检查:gdcc.hsps.server.portal.reginfo.mt.TPortalMtHosplInfoIServiceImpl 路径是否正确。

5分

在tPortalMtHosplInfoIService中set tPortalMtHosplInfoIService? 楼主是你淘气了吧。

 
经过长时间的检查,发现不知为何配置文件会莫名其妙的被改了(我觉得肯定不是我自己改的),如小写变大写,scope改成了class,t变成了r等

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明java创建bean Unable to instantiate Action
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!