4 Replies Latest reply on Jun 4, 2008 10:00 AM by Piergiorgio Lucidi

    Struts bridge

    Viet Master

      I have integrated Struts bridge with JBoss Portal. It is only available in CVS head only.

      The bridge is based on jetspeed 2.0 M2 bridge and provide an experimental implementation of it.

      First you need to read the documentation provided by the struts bridge that explains how it works and what are the limitations of the bridge regarding the application to convert.

      The struts mail demo application works with it. Here is what needs to be modified :

      1/
      in WEB-INF/portlet.xml change the bridge implementation value

       ...
       <init-param>
       <name>ServletContextProvider</name>
       <value>org.jboss.portal.bridge.JBossServletContextProvider</value>
       </init-param>
       ...
      

      That will tell the StrutsPortlet to use the specific implementation of the ServletContextProvider implementation that make it works into JBoss

      2/
      add WEB-INF/jboss-portlet.xml containing
      <portlet-app>
       <portlet>
       <portlet-name>StrutsPortletDemo</portlet-name>
       <!-- Use the specific struts container configuration -->
       <config-name>StrutsPortlet</config-name>
       </portlet>
      </portlet-app>
      

      that tells portlet deployer to use an alternative configuration specific to struts portlets

      3/ add WEB-INF/portlet-instances.xml
      <instances>
       <instance>
       <instance-name>StrutsPortletDemoInstance</instance-name>
       <component-ref>StrutsPortletDemo</component-ref>
       </instance>
      </instances>
      

      that will create an instance of the portlet

      4/ add WEB-INF/struts-pages.xml
      <pages>
       <portal-name>default</portal-name>
       <page>
       <page-name>struts</page-name>
       <window>
       <window-name>StrutsPortletWindow</window-name>
       <instance-ref>/struts-demo.StrutsPortletDemo.StrutsPortletDemoInstance</instance-ref>
       <region>center</region>
       <height>0</height>
       </window>
       </page>
      </pages>
      

      that create a page in the default portal containing the instance we have created

      5/ have the struts bridge jar in the web application : WEB-INF/lib/portals-bridges-struts-0.2.jar

      note that :

      1/ not all struts applications can be converted to work into portlet
      2/ the taglib used by the integration is different from the one provided with struts in order to integrate properly with PortletURL


      You can dowload the bundled sample here
      http://docs.jboss.org/jbportal/samples/struts-demo-for-jboss-portal.zip

        • 1. Re: Struts bridge
          Danny Hon Newbie

          When we use request.setAttribute(...) from within the execute method of an Action class, the attribute cannot be read from the JSP.

          request.getSession().setAttribute(...) works though. Is this a bug or limitation?

          • 2. Re: Struts bridge
            Craig Rutfield Newbie


            I can use some help here. I am missing something which I hope is a basic point - setting up the initial URL. I am getting an 'invalid path' when I replace the /Welcome items in struts-config.xml.

            This posting was very helpful. I have the demo app running and can rebuild/modify it within eclipse.

            I have read through the documentation and it appears as though my application (even though it uses tiles) is a good candidate.

            The application's URL is of the form: http://servername/recruit/public/3110001/postings.do

            The action path seems fine... /public/311*/postings

            Instead of /Welcome.do, I want to handle the above URL.

            1. What should the path be in struct-config global forward definitions?
            2. What directories are then needed under WEB-INF to be consistent?

            CR

            • 3. Re: Struts bridge
              Arun AV Newbie

              Hi
              I am new to struts portlet. I downloaded the struts mail demo war file.
              All the changes have been made as u specified in the forum.

              But after deploying it, i get class not found exception

              2007-10-06 14:54:06,198 ERROR [STDERR] java.lang.ClassNotFoundException: org.jboss.portal.bridge.JBossServletContextProvider
              2007-10-06 14:54:06,198 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
              2007-10-06 14:54:06,198 ERROR [STDERR] at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
              2007-10-06 14:54:06,198 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
              2007-10-06 14:54:06,198 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
              2007-10-06 14:54:06,198 ERROR [STDERR] at java.lang.Class.forName(Class.java:164)
              2007-10-06 14:54:06,198 ERROR [STDERR] at org.apache.portals.bridges.struts.StrutsPortlet.init(StrutsPortlet.java:130)
              2007-10-06 14:54:06,214 ERROR [STDERR] at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.initPortlet(PortletContainerImpl.java:359)
              2007-10-06 14:54:06,214 ERROR [STDERR] at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.start(PortletContainerImpl.java:233)
              2007-10-06 14:54:06,214 ERROR [STDERR] at org.jboss.portal.portlet.impl.container.PortletApplicationContextImpl.startPortletApplication(PortletApplicationContextImpl.java:130)


              • 4. Re: Struts bridge
                Piergiorgio Lucidi Novice

                If you are using JBoss Portal 2.6.5 you must define the ServletContextProvider in this way:

                <init-param>
                 <name>ServletContextProvider</name>
                 <value>org.jboss.portal.portlet.bridge.JBossServletContextProvider</value>
                </init-param>
                


                In this version of JBoss the package of the class implementing org.apache.portals.bridges.common.ServletContextProvider is different than the previous version: the new package is org.jboss.portal.portlet.bridge.