i am trying to create a restful service using struts2. when i added the struts2-rest-plugin in the dependency struts action is not taking the default method(execute).It is looking for create() or index() methods .
struts2-convention-plugin and struts2-rest-plugin
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
I have all these constants in struts.xml
<constant name="struts.devMode" value="false" />
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.action.extension" value="action," />
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources,errors,global" />
<constant name="struts.multipart.maxSize" value="2097152" />
<constant name="struts.ui.theme" value="css_xhtml" />
<constant name="struts.codebehind.pathPrefix" value="/WEB-INF/pages/" />
<constant name="struts.enable.SlashesInActionNames" value="true" />
<constant name="struts.convention.action.disableScanning" value="true" />
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false" />
<constant name="struts.convention.package.locators" value="controller"/>
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="false"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
I am getting the error when i execute the web project
ERROR [tomcat-http--34] Dispatcher.error(38) | Exception occurred during processing request: com.vxl.appanalytix.webapp.action.LoginAction.create()
java.lang.NoSuchMethodException: com.vxl.appanalytix.webapp.action.LoginAction.create()
at java.lang.Class.getMethod(Class.java:1655)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:138)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
my project has spring for dependency management, insted of using the spring MCV we planned for using struts2.I tried to use spring restful service but I was getting some dispacher error so i moved to struts2-rest-plugin. here the controller class i implemented as a service has methods like index() and create() for HTTP GET and PUT respectivelly. how exactly the rest plugin works.
value
for constant namestruts.action.extension
correct.? Why is there a comma..? Is it a typo.? – user2339071