Я начинаю использовать плагин Struts2 Rest в нашем приложении Spring.
Давайте начнем с нашего struts.xml :
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="lang/messages" />
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
<constant name="struts.mapper.class" value="rest" />
<package name="default">
<action name="document" class="DocumentRestaction" />
</package>
</struts>
Затем весной я делаю следующее (чтобы узнать, введена ли строка):
<bean name="DocumentRestaction" class="be.example.actions.DocumentRestaction">
<property name="injected" value="Oh Hai" />
</bean>
Я делаю POST
запрос на URL /documents
и в итоге получаю метод create()
, отлично! В отладке моя injected
переменная вводится. Но когда я продолжаю отладку, я получаю следующее исключение:
4129 [http-8080-2] ERROR org.apache.struts2.rest.RestActionInvocation - Exception processing the result.
java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [DocumentRestaction]
at org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)
at org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:379)
at org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:268)
at com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:227)
at org.apache.struts2.rest.RestActionInvocation.executeResult(RestActionInvocation.java:221)
at org.apache.struts2.rest.RestActionInvocation.processResult(RestActionInvocation.java:198)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:146)
at com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:147)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: DocumentRestaction
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.struts2.util.ClassLoaderUtils.loadClass(ClassLoaderUtils.java:111)
at org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:98)
... 27 more
Но класс был найден .. (я закончил в create
), почему он так говорит? И самое главное, что я делаю не так?
Я использую Spring v3.0.5, struts2-rest-plugin v2.3.1, struts2-core v2.3.1 и struts2-spring-plugin 2.3.1