ssh整合报错:Unable to instantiate Action, studentAction, defined for 'StudentAction_add' in namespace '

报错代码:Unable to instantiate Action, studentAction,  defined for 'StudentAction_add' in namespace '/'studentAction - action - file:/E:/workspace/Eclipse/SSH/target/classes/struts.xml:8:69
    at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:320)
    at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:401)
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:201)
    at org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:57)
    at org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:32)
    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:60)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
    at org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:79)
    at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:141)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:96)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: studentAction
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1308)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1136)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:179)
    at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:129)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:252)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:168)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:177)
    at com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:40)
    at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:142)
    at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:301)
    ... 28 more
ERROR DefaultDispatcherErrorHandler Exception occurred during processing request: Unable to instantiate Action, studentAction,  defined for 'StudentAction_add' in namespace '/'studentAction
 Unable to instantiate Action, studentAction,  defined for 'StudentAction_add' in namespace '/'studentAction - action - file:/E:/workspace/Eclipse/SSH/target/classes/struts.xml:8:69
    at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:320)
    at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:401)
    at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:201)
    at org.apache.struts2.factory.StrutsActionProxy.prepare(StrutsActionProxy.java:57)
    at org.apache.struts2.factory.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:32)
    at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:60)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
    at org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:79)
    at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:141)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:96)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: studentAction
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1308)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1136)
    at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:179)
    at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:129)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:252)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:168)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:177)
    at com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:40)
    at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:142)
    at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:301)
    ... 28 more

解决办法:

1、如果项目没有使用Spring,则struts.xml配置文件中,这个action的class属性的路径没有写完整,应该是包名.类名

2、如果项目使用了Spring,那就是applicationContext.xml里面没有为这个action定义bean。这样strus.xml中的对应action的class属性的值就是Spring配置文件中bean的id。

 

你可能感兴趣的:(ssh整合报错:Unable to instantiate Action, studentAction, defined for 'StudentAction_add' in namespace ')