Hi
I've got a web application which uses both plain servlets and struts; and that causes me some headache.
First I tried to strap up spring in struts-config.xml as described in http://struts.sourceforge.net/struts-spring/#usage. Then my servlets does'nt work. I used the WebApplicationContextUtils to get the application context, but only got null values from it. Appearently the servlet context in struts is not the same as used in plain servlets.
Then I tried to strap up spring from web.xml. Now the DelegatingActionProxy, which delegates to and injects my actions, got cranky and gave me this exception:
java.lang.IllegalStateException: Could not find ContextLoaderPlugIn's WebApplicationContext as ServletContext attribute [org.springframework.web.struts.ContextLoaderPlugIn .CONTEXT.] - did you register [org.springframework.web.struts.ContextLoaderPlugIn]?
at org.springframework.web.struts.DelegatingActionUti ls.getRequiredWebApplicationContext(DelegatingActi onUtils.java:71)
at org.springframework.web.struts.DelegatingActionPro xy.getWebApplicationContext(DelegatingActionProxy. java:136)
at org.springframework.web.struts.DelegatingActionPro xy.getDelegateAction(DelegatingActionProxy.java:11 9)
at org.springframework.web.struts.DelegatingActionPro xy.execute(DelegatingActionProxy.java:104)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
I expect that setting up spring in both web.xml and struts-config.xml would not be a good idea.
So I ended setting spring up from web.xml and manually using WebApplicationContextUtils to get access to spring beans from both plain servlets and struts. Why this work I don't know :-(.
Does anyone know a better solution?
have a nice day
ThorÅgeEldby
--


Reply With Quote
. 