Hi,
I'm putting togther a proof of concept to try to prove that converting our web-app to Spring 1.2 is a worthwhile investment. Anway, I'm having trouble making my Struts actions Spring managed, (note that it works fine if my struts actions extends ActionSupport).
In order to make my struts actions Spring managed I have:
1) defined the action-servlet.xml being:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean name="/setup" class="MyAction">
<property name="dao">
<ref bean="dao"/>
</property>
</bean>
</beans>
2) added the following to struts-config.xml:
<plug-in className="org.springframework.web.struts.ContextL oaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/action-servlet.xml, /WEB-INF/applicationContext.xml"/>
</plug-in>
3) Changed my struts-config.xml so that the actions point to DelegatingActionProxy, ie:
<action path="/setup" name="setupForm" type="org.springframework.web.struts.DelegatingAct ionProxy" scope="request">
<forward name="success" path="findings"></forward>
</action>
4) The outline of my struts action is:
public class MyAction extends Action {
private Dao dao;
...
public ActionForward execute(...) {
...
}
public void setDao(Dao dao) {
this.dao = dao;
}
However, when I start Tomcat I get the following stack trace:
2005-07-05 16:27:30 StandardContext[/test]Loading Spring root WebApplicationContext
2005-07-05 16:28:56 StandardContext[/test]Initializing WebApplicationContext for Struts ActionServlet 'action', module ''
2005-07-05 16:29:23 StandardContext[/test]action: null
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '/setup' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Can't resolve reference to bean 'dao' while setting property 'dao'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.OutOfMemoryError: null
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'findingDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.OutOfMemoryError: null
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.OutOfMemoryError: null
java.lang.OutOfMemoryError
2005-07-05 16:29:23 StandardContext[/test]Marking servlet action as unavailable
2005-07-05 16:29:23 StandardContext[/test]Servlet /test threw load() exception
javax.servlet.UnavailableException
at org.apache.struts.action.ActionServlet.initModuleP lugIns(ActionServlet.java:1169)
at org.apache.struts.action.ActionServlet.init(Action Servlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:4013)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4357)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478)
at org.apache.catalina.core.StandardService.start(Sta ndardService.java:480)
at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:287)
at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:425)
2005-07-05 16:29:27 StandardContext[/balancer]org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRul e: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterR ule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingR ule: Redirect URL: http://jakarta.apache.org]]
2005-07-05 16:29:28 StandardContext[/jsp-examples]ContextListener: contextInitialized()
2005-07-05 16:29:28 StandardContext[/jsp-examples]SessionListener: contextInitialized()
2005-07-05 16:29:28 StandardContext[/servlets-examples]ContextListener: contextInitialized()
2005-07-05 16:29:28 StandardContext[/servlets-examples]SessionListener: contextInitialized()


Reply With Quote