You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Doug Tangren <d....@gmail.com> on 2006/10/25 18:49:55 UTC

help integrating struts and spring 2

Hi.  I have been using Struts 1.2.9 for a while and just started  
using Spring 2.0.  I am trying to integrate the two an am running  
into trouble.  I am following Springs docs @ http:// 
static.springframework.org/spring/docs/2.0.x/reference/ 
webintegration.html#struts-actionsupport  and I tried the easier of  
the two recommended approaches, making my actions subclass Spring's  
DispatchActionSupport class instead of Struts' Action class.  This  
example below is the example given in Spring's docs.

public class UserAction extends DispatchActionSupport {

     public ActionForward execute(ActionMapping mapping,
                                  ActionForm form,
                                  HttpServletRequest request,
                                  HttpServletResponse response)  
throws Exception {
         if (log.isDebugEnabled()) {
             log.debug("entering 'delete' method...");
         }
         WebApplicationContext ctx = getWebApplicationContext();
         UserManager mgr = (UserManager) ctx.getBean("userManager");
         // talk to manager for business logic
         return mapping.findForward("success");
     }
}


  I am deploying to Tomcat and am getting the following error.  What  
have been your approaches to integrate Struts and Spring?



java.lang.IllegalStateException: No WebApplicationContext found: no  
ContextLoaderListener registered?
	 
org.springframework.web.context.support.WebApplicationContextUtils.getRe 
quiredWebApplicationContext(WebApplicationContextUtils.java:86)
	 
org.springframework.web.struts.DelegatingActionUtils.findRequiredWebAppl 
icationContext(DelegatingActionUtils.java:148)
	 
org.springframework.web.struts.DispatchActionSupport.initWebApplicationC 
ontext(DispatchActionSupport.java:98)
	org.springframework.web.struts.DispatchActionSupport.setServlet 
(DispatchActionSupport.java:78)
	org.apache.struts.action.RequestProcessor.processActionCreate 
(RequestProcessor.java:295)
	org.apache.struts.action.RequestProcessor.process 
(RequestProcessor.java:218)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Doug Tangren
d.tangren@gmail.com




Re: help integrating struts and spring 2

Posted by James Mitchell <jm...@apache.org>.
Perhaps you skipped a step.  Scroll up that page a bit to the section  
"15.2. Common configuration".

Do that and try it again.


--
James Mitchell
678.910.8017




On Oct 25, 2006, at 12:49 PM, Doug Tangren wrote:

> Hi.  I have been using Struts 1.2.9 for a while and just started  
> using Spring 2.0.  I am trying to integrate the two an am running  
> into trouble.  I am following Springs docs @ http:// 
> static.springframework.org/spring/docs/2.0.x/reference/ 
> webintegration.html#struts-actionsupport  and I tried the easier of  
> the two recommended approaches, making my actions subclass Spring's  
> DispatchActionSupport class instead of Struts' Action class.  This  
> example below is the example given in Spring's docs.
>
> public class UserAction extends DispatchActionSupport {
>
>     public ActionForward execute(ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest request,
>                                  HttpServletResponse response)  
> throws Exception {
>         if (log.isDebugEnabled()) {
>             log.debug("entering 'delete' method...");
>         }
>         WebApplicationContext ctx = getWebApplicationContext();
>         UserManager mgr = (UserManager) ctx.getBean("userManager");
>         // talk to manager for business logic
>         return mapping.findForward("success");
>     }
> }
>
>
>  I am deploying to Tomcat and am getting the following error.  What  
> have been your approaches to integrate Struts and Spring?
>
>
>
> java.lang.IllegalStateException: No WebApplicationContext found: no  
> ContextLoaderListener registered?
> 	 
> org.springframework.web.context.support.WebApplicationContextUtils.get 
> RequiredWebApplicationContext(WebApplicationContextUtils.java:86)
> 	 
> org.springframework.web.struts.DelegatingActionUtils.findRequiredWebAp 
> plicationContext(DelegatingActionUtils.java:148)
> 	 
> org.springframework.web.struts.DispatchActionSupport.initWebApplicatio 
> nContext(DispatchActionSupport.java:98)
> 	org.springframework.web.struts.DispatchActionSupport.setServlet 
> (DispatchActionSupport.java:78)
> 	org.apache.struts.action.RequestProcessor.processActionCreate 
> (RequestProcessor.java:295)
> 	org.apache.struts.action.RequestProcessor.process 
> (RequestProcessor.java:218)
> 	org.apache.struts.action.ActionServlet.process(ActionServlet.java: 
> 1194)
> 	org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>
>
> Doug Tangren
> d.tangren@gmail.com
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org