Unable to instantiate Action, XXXAction, defined for 'xx' in namespace 'xx'报错解决
2017-03-11 21:11
246 查看
ssh整合中这里出现了这个错误,原因出现在无法将action中的属性初始化为bean.。
具体完整报错为:http-500
Unable to instantiate Action, loginAction, defined for 'login' in namespace '/'loginAction
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.ClassNotFoundException: loginAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157)
com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107)
com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:223)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
代码具体原因:这里的struts.xml和applicationContext.xml配置文件都没有写错误。就去action中分析代码。
这里发现在action中定义了service层的变量userservice;采用的是注解方式注入,即在setter方法前写注释@Resource(name="")。
但setter的位置是在eclipse中用Alt+shift+s自动生成的,这里把setter生成到了整个action类的最下边,当改到action中的方法之前后,程序不再报错。
但这里其实很有可能是配置文件的错误,但是错误的原因都是一样的,有可能是没有注入到action属性中,有可能在配置文件中找不到配置注入的包,或者字母拼写错误等。
具体完整报错为:http-500
Unable to instantiate Action, loginAction, defined for 'login' in namespace '/'loginAction
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
root cause
java.lang.ClassNotFoundException: loginAction
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157)
com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107)
com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:223)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
代码具体原因:这里的struts.xml和applicationContext.xml配置文件都没有写错误。就去action中分析代码。
这里发现在action中定义了service层的变量userservice;采用的是注解方式注入,即在setter方法前写注释@Resource(name="")。
但setter的位置是在eclipse中用Alt+shift+s自动生成的,这里把setter生成到了整个action类的最下边,当改到action中的方法之前后,程序不再报错。
但这里其实很有可能是配置文件的错误,但是错误的原因都是一样的,有可能是没有注入到action属性中,有可能在配置文件中找不到配置注入的包,或者字母拼写错误等。
相关文章推荐
- Unable to instantiate Action, xxxAction, defined for 'xxx' in namespace '/'xxxAction解决方案
- Unable to instantiate Action, xxxAction, defined for 'xxx' in namespace '/'xxxAction解决方案
- Unable to instantiate Action, xxxAction, defined for ‘xxx’ in namespace ‘/’xxxAction
- SSH开发 报错:Unable to instantiate Action, controller.MsgController, defined for'show' in namespace '
- Unable to instantiate Action, departmentAction, defined for 'department_list' in namespace '/'depart
- Unable to instantiate Action, xxxAction, defined for 'xxx' in namespace '/'xxxAction解决方式
- Unable to instantiate Action, loginAction, defined for 'login' in namespace
- Unable to instantiate Action, Action, defined for 解决方法
- Unable to instantiate Action, xxxAction, defined for ‘xxx’ in namespace ‘/’xxxAction解决方案
- HTTP Status 500 - Unable to instantiate Action, customerAction, defined for 'CustomerAction_list' in
- ssh报 HTTP Status 500 - Unable to instantiate Action, com.web.action.UserAction, defined for 'login'
- Unable to instantiate Action, xxxAction, defined for ‘xxx’ in namespace ‘/’xxxAction
- spring-error-1 Unable to instantiate Action, com.fxb.sms.web.action.AdminAction, defined for 'Adm
- Unable to instantiate Action错误的解决
- Unable to instantiate Action错误的解决
- 出现"Unable to instantiate Action,xxxxx, defined for 'login' in namespace '/' xxxxx 解决办法
- Unable to instantiate Action, defined for t' in namespace '/'XXXAction
- Unable to instantiate Action解决
- java.lang.RuntimeException: Unable to instantiate activity ComponentInfo异常解决
- [VxW]Unable to add route to xx.xx.xx.xx; errno = 0xffffffff.问题解决