Announcement Announcement Module
Collapse
No announcement yet.
Integrating Tiles with Spring using Struts Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integrating Tiles with Spring using Struts

    Hi,

    I've read through the forums and cant find the answer to my tiles integration problem with Spring (v1.1.5) using Struts (v1.2.4) in the web tier.

    Any help to this problem is appreciated! The stack trace and relevant XML files follow:

    StackTrace:
    javax.servlet.ServletException: Error creating bean with name 'tilesConfigurer' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.web.servlet.view.tiles.TilesCo nfigurer@30d83d] does not run in a WebApplicationContext but in: org.springframework.context.support.ClassPathXmlAp plicationContext: display name [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=6549662]; startup date [Tue Apr 05 21:47:18 MDT 2005]; root of context hierarchy
    at org.apache.struts.action.RequestProcessor.processE xception(RequestProcessor.java:516)
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:423)
    at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:226)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1164)
    at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:397)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:696)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:809)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:146)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:209)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:596)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:948)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:144)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:596)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:948)
    at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2358)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:133)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:596)
    at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.java:118)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:594)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:116)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:594)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:948)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:127)
    at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:596)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:948)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:152)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Unknown Source)


    applicationContext.xml fragment:
    <beans>
    <bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles. TilesConfigurer">
    <property name="factoryClass">
    <value>org.apache.struts.tiles.xmlDefinition.I18nF actorySet</value>
    </property>
    <property name="definitions">
    <list>
    <value>/WEB-INF/tiles-layout.xml</value>
    </list>
    </property>
    </bean>

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="requestContextAttribute">
    <value>requestContext</value>
    </property>
    <property name="viewClass">
    <value>org.springframework.web.servlet.view.tiles. TilesView</value>
    </property>
    </bean>
    ...
    </beans>

    tiles-layout.xml:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE tiles-definitions PUBLIC
    "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
    "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
    <tiles-definitions>
    <definition name="test"/>
    </tiles-definitions>

    I've tried it without the ViewResolver (which I think is required for SPring MVC), and with the Struts-config plugin?

    thanks,

    Dean

  • #2
    It looks like you need to define the "tilesConfigurer" bean in a context file that's loaded by the ContextLoaderPlugin or by the DispatcherServlet
    in web.xml.

    Matt

    Comment


    • #3
      hello

      i'm getting the same exception when using struts-menu with spring:

      2006-06-22 09:11:32,346 ERROR StandardWrapper.Throwable in (ApplicationContext.java:675)
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'menu' defined in class path resource [applicationContext-coreResources.xml]: Initialization of bean failed; nested exception is org.springframework.context.ApplicationContextExce ption: Failed to initialize Struts Menu repository; nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [net.sf.navigator.menu.MenuLoader@161def0] does not run in a WebApplicationContext but in: org.springframework.context.support.ClassPathXmlAp plicationContext: display name [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=9423995]; startup date [Thu Jun 22 09:11:13 CEST 2006]; root of context hierarchy
      Caused by:
      org.springframework.context.ApplicationContextExce ption: Failed to initialize Struts Menu repository; nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [net.sf.navigator.menu.MenuLoader@161def0] does not run in a WebApplicationContext but in: org.springframework.context.support.ClassPathXmlAp plicationContext: display name [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=9423995]; startup date [Thu Jun 22 09:11:13 CEST 2006]; root of context hierarchy
      Caused by:
      java.lang.IllegalStateException: WebApplicationObjectSupport instance [net.sf.navigator.menu.MenuLoader@161def0] does not run in a WebApplicationContext but in: org.springframework.context.support.ClassPathXmlAp plicationContext: display name [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=9423995]; startup date [Thu Jun 22 09:11:13 CEST 2006]; root of context hierarchy
      at org.springframework.web.context.support.WebApplica tionObjectSupport.getWebApplicationContext(WebAppl icationObjectSupport.java:71)
      at org.springframework.web.context.support.WebApplica tionObjectSupport.getServletContext(WebApplication ObjectSupport.java:86)
      at net.sf.navigator.menu.MenuLoader.initApplicationCo ntext(MenuLoader.java:53)

      Any help appreciated...

      Regards
      Angela

      Comment


      • #4
        Hi,

        Here is how I have it configured and it works. You need to get the views.properties in the classpath. I have placed it under WEB-INF/classes

        <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.Resour ceBundleViewResolver">
        <property name="order" value="1"/>
        <property name="basename">
        <value>views</value>
        </property>
        </bean>

        <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles. TilesConfigurer">
        <property name="definitions">
        <list>
        <value>/WEB-INF/tiles-defs.xml</value>
        </list>
        </property>
        </bean>

        Hope this helps...
        regards

        Comment


        • #5
          Hi

          I have tried using the above approach - I have defined the tilesConfigurer bean in an xml file that is loaded in web.xml. It does not work. Is there some kind of conflict between using tiles in an application that uses a combination of struts and tiles?

          Does anyone have an answer to this problem? I really, really, really need some help.

          Thanks

          Comment


          • #6
            As I understand from Rob Harrop's Pro Spring book, chapter on integrating Struts with Spring, is that the normal methods of using Tiles with Spring MVC will *not* work with Struts. TilesConfigurer will not work with Struts actions, so you will need to configure the tiles support in the Struts configuration files instead.

            Glen

            Comment


            • #7
              Hi Glen,

              I have tried every possible combination I could think of, including yours. That was the first thing I tried. It doesn't work, definitely not, the tiles definitions are all correct and mirror the rest of the (struts) application exactly.

              Is there something in a strut action that loads a tiles file? I would have thought there would be more information about integrating spring into struts, as struts is being phased out, yet nothing I have come across will work.

              Comment


              • #8
                I use Spring MVC so I don't know much about Struts. But if you are configuring your struts-config.xml correctly[1], it *should* work properly. I wonder if you can get more help on the struts-users mailing list. This appears to be more a Struts question than a Spring one.

                Glen

                [1] http://pc-science.blogspot.com/2006/...uts-tiles.html

                Comment

                Working...
                X