I am converting my existing struts 2 application to serve through some rest based services also.
I have used two plugins, struts2-rest plugin and struts-convention plugin,
Along with these I have also used asm.jar because above was giving a class not found exception which was there in asm jar.
I want to have both the functionalities as ..my normal struts action mappings should also work along with rest urls.
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Overwrite Convention -->
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
<constant name="struts.mapper.class"value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper" />
<constant name="struts.mapper.prefixMapping" value="/rest:rest,:struts" />
<package name="userlogin" extends="struts-default" namespace="/">
<action>
......
</action>
</package>
<package name="secureAction" extends="struts-default,json-default"
namespace="/secure">
<interceptors>
...............
</interceptors>
<default-interceptor-ref name="secureStack" />
<global-results>
.............
</global-results>
<global-exception-mappings>
..............
</global-exception-mappings>
</package>
<include file=".....xml" />
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
.........
<display-name>strutsTest</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
....
</welcome-file-list>
<servlet>
<description></description>
<display-name>Logger</display-name>
<servlet-name>Logger</servlet-name>
<servlet-class>...........</servlet-class>
<init-param>
<param-name>log4j-properties-location</param-name>
<param-value>WEB-INF/log4j.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Logger</servlet-name>
<url-pattern>/Logger</url-pattern>
</servlet-mapping>
I m not able to find any error..
what i see on screen when i run either struts action based mapping or rest url ..is :
Struts has detected an unhandled exception:
Messages:
com.thoughtworks.xstream.XStream
com/thoughtworks/xstream/XStream
java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
File: org/apache/catalina/loader/WebappClassLoader.java
Line number: 1,516
ive solved the problem with customMapper..
this is my custom mapper class....
........................................... my struts.xml is as follows......
these are the libraries im using ..
make sure you use compatible library versions....