struts2 with rest service

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

struts2 with rest service

john lee
To whom it may concern, 
my struts+spring+hibernate+mysql works fine, but try to embed the rest service in the application and failed to start.
my adding/change is the following
WEB-INF/lib  (add the following jar)    json-lib-2.3-jdk15.jar
    struts2-rest-plugin-2.3.32.jar

WEB-INF/classes/struts.xml (add the following line with red font)
<struts>
  <include file="struts-default.xml"/>
  <constant name="struts.action.extension" value="xhtml,,xml,json,action"/>  <constant name="struts.mapper.class" value="org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper" />  <constant name="struts.mapper.prefixMapping" value="/rest:rest,:struts"/>  <constant name="struts.convention.action.suffix" value="Controller"/>  <constant name="struts.convention.action.mapAllMatches" value="true"/>  <constant name="struts.convention.default.parent.package" value="rest-default"/>  <constant name="struts.convention.package.locators" value="example"/>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
  <package name="default" extends="json-default">
after start application, but in catalina.out see the following error, i did copy struts-plugin.xml into WEB-INF/classes/.
thanks in advance
john

*******************************************************************
SEVERE: Exception starting filter struts2Unable to load configuration. - bean - jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:504)        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:278)        Caused by: Unable to load configuration. - bean - jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)        at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:978)        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)        ... 15 moreCaused by: Unable to load bean: type:com.opensymphony.xwork2.ActionProxyFactory class:org.apache.struts2.rest.RestActionProxyFactory - bean - jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:247)        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:240)        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)        ... 18 moreCaused by: Bean type interface com.opensymphony.xwork2.ActionProxyFactory with the name rest has already been loaded by bean - file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes/struts-plugin.xml:30:130 - bean - jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:231)        ... 21 more
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: struts2 with rest service

Ken McWilliams
Have you also included the struts2-conventions-plugin?

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
            <version>2.5.10.1</version>
        </dependency>

struts2-rest-plugin most definitely depends on struts2-conventions-plugin
but it isn't a declared dependency. I've thought that was strange for some
time. All the bean configurations such as struts.convention.action.suffix,
couldn't work otherwise.

On Wed, Jul 19, 2017 at 1:10 PM, john lee <[hidden email]>
wrote:

> To whom it may concern,
> my struts+spring+hibernate+mysql works fine, but try to embed the rest
> service in the application and failed to start.
> my adding/change is the following
> WEB-INF/lib  (add the following jar)    json-lib-2.3-jdk15.jar
>     struts2-rest-plugin-2.3.32.jar
>
> WEB-INF/classes/struts.xml (add the following line with red font)
> <struts>
>   <include file="struts-default.xml"/>
>   <constant name="struts.action.extension" value="xhtml,,xml,json,action"/>
> <constant name="struts.mapper.class" value="org.apache.struts2.
> dispatcher.mapper.PrefixBasedActionMapper" />  <constant
> name="struts.mapper.prefixMapping" value="/rest:rest,:struts"/>
> <constant name="struts.convention.action.suffix" value="Controller"/>
> <constant name="struts.convention.action.mapAllMatches" value="true"/>
> <constant name="struts.convention.default.parent.package"
> value="rest-default"/>  <constant name="struts.convention.package.locators"
> value="example"/>
> <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"
> />
>   <package name="default" extends="json-default">
> after start application, but in catalina.out see the following error, i
> did copy struts-plugin.xml into WEB-INF/classes/.
> thanks in advance
> john
>
> *******************************************************************
> SEVERE: Exception starting filter struts2Unable to load configuration. -
> bean - jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-
> INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130
> at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:504)
>     at org.apache.struts2.dispatcher.ng.InitOperations.
> initDispatcher(InitOperations.java:74)        at
> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
> init(StrutsPrepareAndExecuteFilter.java:57)        at
> org.apache.catalina.core.ApplicationFilterConfig.initFilter(
> ApplicationFilterConfig.java:278)        Caused by: Unable to load
> configuration. - bean - jar:file:/var/apache-tomcat-7.
> 0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.
> 3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.
> config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
>       at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:978)
>       at org.apache.struts2.dispatcher.Dispatcher.init_
> PreloadConfiguration(Dispatcher.java:446)        at
> org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
> ... 15 moreCaused by: Unable to load bean: type:com.opensymphony.xwork2.ActionProxyFactory
> class:org.apache.struts2.rest.RestActionProxyFactory - bean -
> jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-
> INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130
> at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.
> register(XmlConfigurationProvider.java:247)        at
> org.apache.struts2.config.StrutsXmlConfigurationProvider.register(
> StrutsXmlConfigurationProvider.java:102)        at
> com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(
> DefaultConfiguration.java:240)        at com.opensymphony.xwork2.
> config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
>       ... 18 moreCaused by: Bean type interface com.opensymphony.xwork2.ActionProxyFactory
> with the name rest has already been loaded by bean -
> file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/
> classes/struts-plugin.xml:30:130 - bean - jar:file:/var/apache-tomcat-7.
> 0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.
> 3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.
> config.providers.XmlConfigurationProvider.register(
> XmlConfigurationProvider.java:231)        ... 21 more
>



--
Sent from my C64 using a 300 baud modem
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: struts2 with rest service

john lee
after i append, the problem is gone, but when i did test, have error message generated.
please see the thread.
thanks in advance.
john



      From: Ken McWilliams <[hidden email]>
 To: Struts Users Mailing List <[hidden email]>; john lee <[hidden email]>
 Sent: Wednesday, July 19, 2017 4:11 PM
 Subject: Re: struts2 with rest service
   
Have you also included the struts2-conventions-plugin?

        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-convention-plugin</artifactId>
            <version>2.5.10.1</version>
        </dependency>

struts2-rest-plugin most definitely depends on struts2-conventions-plugin
but it isn't a declared dependency. I've thought that was strange for some
time. All the bean configurations such as struts.convention.action.suffix,
couldn't work otherwise.

On Wed, Jul 19, 2017 at 1:10 PM, john lee <[hidden email]>
wrote:

> To whom it may concern,
> my struts+spring+hibernate+mysql works fine, but try to embed the rest
> service in the application and failed to start.
> my adding/change is the following
> WEB-INF/lib  (add the following jar)    json-lib-2.3-jdk15.jar
>    struts2-rest-plugin-2.3.32.jar
>
> WEB-INF/classes/struts.xml (add the following line with red font)
> <struts>
>  <include file="struts-default.xml"/>
>  <constant name="struts.action.extension" value="xhtml,,xml,json,action"/>
> <constant name="struts.mapper.class" value="org.apache.struts2.
> dispatcher.mapper.PrefixBasedActionMapper" />  <constant
> name="struts.mapper.prefixMapping" value="/rest:rest,:struts"/>
> <constant name="struts.convention.action.suffix" value="Controller"/>
> <constant name="struts.convention.action.mapAllMatches" value="true"/>
> <constant name="struts.convention.default.parent.package"
> value="rest-default"/>  <constant name="struts.convention.package.locators"
> value="example"/>
> <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"
> />
>  <package name="default" extends="json-default">
> after start application, but in catalina.out see the following error, i
> did copy struts-plugin.xml into WEB-INF/classes/.
> thanks in advance
> john
>
> *******************************************************************
> SEVERE: Exception starting filter struts2Unable to load configuration. -
> bean - jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-
> INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130
> at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:504)
>    at org.apache.struts2.dispatcher.ng.InitOperations.
> initDispatcher(InitOperations.java:74)        at
> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
> init(StrutsPrepareAndExecuteFilter.java:57)        at
> org.apache.catalina.core.ApplicationFilterConfig.initFilter(
> ApplicationFilterConfig.java:278)        Caused by: Unable to load
> configuration. - bean - jar:file:/var/apache-tomcat-7.
> 0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.
> 3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.
> config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
>      at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:978)
>      at org.apache.struts2.dispatcher.Dispatcher.init_
> PreloadConfiguration(Dispatcher.java:446)        at
> org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
> ... 15 moreCaused by: Unable to load bean: type:com.opensymphony.xwork2.ActionProxyFactory
> class:org.apache.struts2.rest.RestActionProxyFactory - bean -
> jar:file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-
> INF/lib/struts2-rest-plugin-2.3.32.jar!/struts-plugin.xml:30:130
> at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.
> register(XmlConfigurationProvider.java:247)        at
> org.apache.struts2.config.StrutsXmlConfigurationProvider.register(
> StrutsXmlConfigurationProvider.java:102)        at
> com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(
> DefaultConfiguration.java:240)        at com.opensymphony.xwork2.
> config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
>      ... 18 moreCaused by: Bean type interface com.opensymphony.xwork2.ActionProxyFactory
> with the name rest has already been loaded by bean -
> file:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/
> classes/struts-plugin.xml:30:130 - bean - jar:file:/var/apache-tomcat-7.
> 0.34/webapps/ecommerce/WEB-INF/lib/struts2-rest-plugin-2.
> 3.32.jar!/struts-plugin.xml:30:130        at com.opensymphony.xwork2.
> config.providers.XmlConfigurationProvider.register(
> XmlConfigurationProvider.java:231)        ... 21 more
>



--
Sent from my C64 using a 300 baud modem


   
Loading...