Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory

cryan
Hi,

I'm "googled out" trying to fix the following issue. Below is trace from running a simple jetty server.
I'm basically blocked at the moment, I'd really appreciate any help. I've tried ver 2.0.6 and 2.0.11.1, if a fix means a hack or manual patch I don't mind, anything to get past this..

Some background info; struts.xml contains:

<struts>
        <constant name="struts.objectFactory" value="spring" />
        <package name="user" extends="struts-default" namespace="/struts2">
               <interceptors>
                    <interceptor name="autowiring"
                                class="interceptor.ActionAutowiringInterceptor"/>
               </interceptors>
         ....etc

and web.xml contains a spring listener, hibernate filter and this:

        <filter>
                <filter-name>struts2</filter-name>
                <filter-class>
                        org.apache.struts2.dispatcher.FilterDispatcher
                </filter-class>
        </filter>
       
        <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

I've tried various suggestions:
- verify no other/multiple struts jars on classpath
- swap two lines in struts-default.xml ie patch the struts core jar:
       <bean class="com.opensymphony.xwork2.ObjectFactory" static="true" />
       <bean class="com.opensymphony.xwork2.util.XWorkConverter" static="true" />
- try minimise the jar set etc..

any other ideas of a fix for this?

-----------------------------------

output from Jetty 6 server:

:INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
:INFO:  started org.mortbay.thread.BoundedThreadPool@1662dc8
:INFO:  Checking Resource aliases
:INFO:  NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
:INFO:  started org.mortbay.jetty.servlet.AbstractSessionManager$NullMetaManager@13bd574
:INFO:  started org.mortbay.jetty.servlet.HashSessionManager@13adc56
:INFO:  started ServletHandler@92bbba
:INFO:  started SessionHandler@162dbb6
:INFO:  started SecurityHandler@146c1d4
/:INFO:  Initializing Spring root WebApplicationContext
:INFO:  failed struts2
:INFO:  failed ContextHandler@1e6696c{/,file:/C:/projects/proj/build/web/}
:INFO:  started Connector null:8000
:INFO:  failed Server@88d319
Exception in thread "main" Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/C:/projects/proj/build/web/WEB-INF/lib/struts2-core-2.0.11.1.jar!/struts-default.xml:8:69
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208)
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:131)
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
        at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
        at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:75)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
        at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:516)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:788)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:345)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:208)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:92)
        at org.mortbay.jetty.Server.doStart(Server.java:140)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
        at betting.server.Main.main(Main.java:130)
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:/C:/projects/proj/build/lib/struts2-core-2.0.11.1.jar!/struts-default.xml:30:72 - bean - jar:file:/C:/projects/proj/build/web/WEB-INF/lib/struts2-core-2.0.11.1.jar!/struts-default.xml:8:69
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)
        ... 17 more
Reply | Threaded
Open this post in threaded view
|

Re: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory

cryan
This problem goes away when I remove most spring 2.5 jars in my web app. Struts2 has a dependency on spring 2.0.5 (in its maven pom file), so any idea why struts2 uses such an old spring version? And when it will move to the latest version?