14 Replies Latest reply on Sep 3, 2006 9:36 AM by yxyang

    Problems with StrutsBridge

    alessandroribeiro

      Hi,

      I'm trying to modify the default StrutsBridge demo application. I created a very simple Struts application, with just one Action. This action just forwards to a static JSP file. I followed the steps in the TXT files of the demo application. My portlet (StrutsHello) now appears on the default MenuPortlet but, when I click on the link to my portletapp's page, I receive an error message inside the portlet window. Here goes the error message:



      java.lang.IllegalStateException: No bridge set
      at org.jboss.portal.bridge.JBossServletContextProvider.getServletContext(JBossServletContextProvider.java:53)
      at org.apache.portals.bridges.struts.StrutsPortlet.getServletContext(StrutsPortlet.java:201)
      at org.apache.portals.bridges.struts.StrutsPortlet.processRequest(StrutsPortlet.java:275)
      at org.apache.portals.bridges.struts.StrutsPortlet.doView(StrutsPortlet.java:263)
      at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:154)

      I've been comparing my application with the demo application, but I have not been able to find out any meaningful differences. Does anyone have a clue about this error ?

      Tks,

      Alessandro Coelho Ribeiro
      alessandro.ribeiro@integritas.com.br


        • 1. Re: Problems with StrutsBridge
          alessandroribeiro

          Some additional information:

          I'm using JBoss Portal 2.0 embedded in JBoss AS 4.0.2.

          I created just one Action file called HelloAction:

          package eco.pep.web.actions;

          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.struts.action.Action;
          import org.apache.struts.action.ActionForm;
          import org.apache.struts.action.ActionForward;
          import org.apache.struts.action.ActionMapping;



          public class HelloAction extends Action {

          public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
          System.out.println("HelloAction");
          return mapping.findForward("success");

          }


          }



          Here is the jboss-app.xml (hellostruts.war):

          <jboss-app>
          <app-name>hellostruts</app-name>
          </jboss-app>


          Here is the portlet.xml file:

          <?xml version="1.0" encoding="UTF-8"?>
          <portlet-app version="1.0">


          <init-param>
          ServletContextProvider
          org.jboss.portal.bridge.JBossServletContextProvider
          </init-param>
          <init-param>
          ViewPage
          /hello
          </init-param>
          <init-param>
          HelpPage
          /hello
          </init-param>
          <portlet-name>StrutsHelloPortlet</portlet-name>
          <display-name>Struts Hello Portlet</display-name>
          This is the Hello World Struts Portlet
          <portlet-class>org.apache.portals.bridges.struts.StrutsPortlet</portlet-class>
          <expiration-cache>-1</expiration-cache>

          <mime-type>text/html</mime-type>
          <portlet-mode>VIEW</portlet-mode>
          <portlet-mode>HELP</portlet-mode>

          <portlet-info>
          Struts Hello Portlet
          <short-title>This is the short title</short-title>
          Struts
          </portlet-info>

          </portlet-app>

          Here is the jboss-portlet.xml file:

          <portlet-app>

          <portlet-name>StrutsHelloPortlet</portlet-name>
          <!-- Use the specific struts container configuration -->

          </portlet-app>


          jboss-service.xml




          jboss-web.xml:

          <?xml version="1.0"?>
          <jboss-web>
          </jboss-web>


          portlet.xml:

          <?xml version="1.0" encoding="UTF-8"?>
          <portlet-app version="1.0">


          <init-param>
          ServletContextProvider
          org.jboss.portal.bridge.JBossServletContextProvider
          </init-param>
          <init-param>
          ViewPage
          /hello
          </init-param>
          <init-param>
          HelpPage
          /hello
          </init-param>
          <portlet-name>StrutsHelloPortlet</portlet-name>
          <display-name>Struts Hello Portlet</display-name>
          This is the Hello World Struts Portlet
          <portlet-class>org.apache.portals.bridges.struts.StrutsPortlet</portlet-class>
          <expiration-cache>-1</expiration-cache>

          <mime-type>text/html</mime-type>
          <portlet-mode>VIEW</portlet-mode>
          <portlet-mode>HELP</portlet-mode>

          <portlet-info>
          Struts Hello Portlet
          <short-title>This is the short title</short-title>
          Struts
          </portlet-info>

          </portlet-app>

          portlet-instances.xml:

          <?xml version="1.0" standalone="yes"?>


          <instance-name>StrutsHelloPortletInstance</instance-name>
          <component-ref>StrutsHelloPortlet</component-ref>



          struts-config.xml:

          <?xml version="1.0" encoding="iso-8859-1"?>
          <!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://struts.apache.org/dtds/struts-config_1_2.dtd">
          <!--
          Default configuration file for examples application.
          Each module also has its own struts-config under: /WEB-INF/$MODULE/
          @version $Revision: 1.9 $ $Date: 2004-09-07 03:50:06 +0100 (Tue, 07 Sep 2004) $
          -->
          <struts-config>
          <global-exceptions />
          <global-forwards>

          </global-forwards>
          <action-mappings>



          </action-mappings>



          <plug-in className="org.apache.struts.plugins.ModuleConfigVerifier"/>



          </struts-config>

          web.xml:

          <?xml version="1.0"?>
          <!DOCTYPE web-app PUBLIC
          "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
          "http://java.sun.com/dtd/web-app_2_3.dtd">
          <web-app>
          <display-name>Prototipo Portlets</display-name>
          Display index and details pages in a Portlet

          <servlet-name>action</servlet-name>
          <servlet-class>org.apache.portals.bridges.struts.PortletServlet</servlet-class>
          <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
          </init-param>
          <load-on-startup>2</load-on-startup>

          <servlet-mapping>
          <servlet-name>action</servlet-name>
          <url-pattern>*.do</url-pattern>
          </servlet-mapping>
          <!-- The Usual Welcome File List -->
          <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
          <welcome-file>index.html</welcome-file>
          <welcome-file>upload.jsp</welcome-file>
          </welcome-file-list>
          <!-- Struts Tag Library Descriptors -->

          <taglib-uri>/tags/struts-bean</taglib-uri>
          <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>


          <taglib-uri>/tags/struts-html</taglib-uri>
          <taglib-location>/WEB-INF/struts-html.tld</taglib-location>


          <taglib-uri>/tags/struts-logic</taglib-uri>
          <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>


          <taglib-uri>/tags/struts-nested</taglib-uri>
          <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>


          </web-app>

          hello-pages.xml:


          <portal-name>default</portal-name>

          <page-name>StrutsHello</page-name>


          <window-name>StrutsHelloPortletWindow</window-name>
          <instance-ref>hellostruts.StrutsHelloPortlet.StrutsHelloPortletInstance</instance-ref>
          center
          0



          <window-name>InternacaoWindow3</window-name>
          <instance-ref>pep-internacao.Internacao.InternacaoInstance</instance-ref>
          true
          left
          0








          • 2. Re: Problems with StrutsBridge
            alessandroribeiro

            An additional information:

            I have created some small portlets so far and they work perfectly fine. I also deployed the Struts Bridge demo and it works fine as well.

            The problem is that I have not been successful creating a very simple Struts application running under a portlet.

            • 3. Re: Problems with StrutsBridge

              did you look at jboss-portlet.xml in the demo ? I think it contains what you need to make this work.

              • 4. Re: Problems with StrutsBridge
                alessandroribeiro

                Hi,

                this is the demo's jboss-portlet.xml:

                <portlet-app>

                <portlet-name>StrutsHelloPortlet</portlet-name>
                <!-- Use the specific struts container configuration -->
                <config-name>StrutsHelloPortlet</config-name>

                </portlet-app>


                I had tried both with and without <config-name> to no avail. I tried to insert this line again in the file, but there is still this "no bridge set" error. And there is also a new error:

                21:15:23,703 ERROR [PortletAppDeployment] No config for the name StrutsHelloPortlet will use the default configuration

                What exactly is this <config-name> used for ?


                • 5. Re: Problems with StrutsBridge
                  alessandroribeiro

                  I have run JBOSS in debug mode. Here is what the application is logging when it receives a request to render a request to my application page.

                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.server.impl.invocation.InvocationImpl] Incoming request with id page.default.StrutsHello
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.ContentTypeInterceptor] Found markup=html_web_4_0, ua=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5, devicedID=netscape7_1_nt_us
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.ContentTypeInterceptor] Found mimeType type text/html for markup=html_web_4_0
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] analyzing layout strategy....
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.server.impl.LayoutServerImpl] get nodesk...
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.server.impl.LayoutServerImpl] found nodesk
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] looking for a layout strategy [default] [StrutsHello] [nodesk] [text/html]
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] got a layout: trying to get the strategy from it...
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] no strategy from the layoutlayout: trying to get named strategy...
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] looking for strategy with name: default
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] found strategy to use: org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] adding region: left
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] adding region: center
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.theme.strategy.StrategyFactory] creating portlet context for: InternacaoWindow3
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.theme.strategy.StrategyFactory] creating portlet context for: StrutsHelloPortletWindow
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.theme.strategy.StrategyFactory] creating strategy context for: nodesk default StrutsHello
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl] evaluating strategy for: org.jboss.portal.core.theme.impl.PortalLayoutImpl@bbb2d0
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl] evaluating portlet: Internacao
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl] evaluating portlet: StrutsHelloPortlet
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] setting layout URI: /nodesk/index.jsp
                  2005-11-23 21:15:31,765 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] done analyzing layout strategy
                  2005-11-23 21:15:31,765 ERROR [org.jboss.portal.core.servlet.CoreServlet] Error
                  java.lang.IllegalStateException: No bridge set
                  at org.jboss.portal.bridge.JBossServletContextProvider.getServletContext(JBossServletContextProvider.java:53)
                  ...


                  I downloaded JBP source code, I found the file where the exception is thrown. I've put a breakpoint in the beginning of the method (JBossServletContextProvider:getServletContext), created a remote debugging session, and found that there is really nothing stored in the ThreadLocal variable. Please, someone who knows the source code well, tell me where I should put additional breakpoints to find out what is wrong with this application.

                  Tks,

                  Alessandro



                  • 6. Re: Problems with StrutsBridge

                    and what happens when you trace the same code for the demo that works ?

                    • 7. Re: Problems with StrutsBridge
                      alessandroribeiro

                      Here is the server.log after I send a request to the demo application:

                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.server.impl.invocation.InvocationImpl] Incoming request with id page.default.struts
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.ContentTypeInterceptor] Found markup=html_web_4_0, ua=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5, devicedID=netscape7_1_nt_us
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.ContentTypeInterceptor] Found mimeType type text/html for markup=html_web_4_0
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] analyzing layout strategy....
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.server.impl.LayoutServerImpl] get nodesk...
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.server.impl.LayoutServerImpl] found nodesk
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] looking for a layout strategy [default] [struts] [nodesk] [text/html]
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] got a layout: trying to get the strategy from it...
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] no strategy from the layoutlayout: trying to get named strategy...
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] looking for strategy with name: default
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] found strategy to use: org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] adding region: center
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.theme.strategy.StrategyFactory] creating portlet context for: StrutsPortletWindow
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.theme.strategy.StrategyFactory] creating strategy context for: nodesk default struts
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl] evaluating strategy for: org.jboss.portal.core.theme.impl.PortalLayoutImpl@bbb2d0
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.theme.strategy.impl.DefaultStrategyImpl] evaluating portlet: StrutsPortletDemo
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] setting layout URI: /nodesk/index.jsp
                      2005-11-23 21:49:49,250 DEBUG [org.jboss.portal.core.invocation.StrategyInterceptor] done analyzing layout strategy
                      2005-11-23 21:49:49,671 DEBUG [org.jboss.portal.core.servlet.CoreServlet] requesting theme: null
                      2005-11-23 21:49:49,687 DEBUG [org.jboss.portal.core.servlet.CoreServlet] using layout returned from the strategy: nodesk uri: /nodesk/index.jsp
                      2005-11-23 21:49:49,687 DEBUG [org.jboss.portal.core.servlet.CoreServlet] got layout to use [nodesk] in app [portal] uri [/nodesk/index.jsp]
                      2005-11-23 21:49:49,687 DEBUG [org.jboss.portal.server.theme.LayoutDispatcher] got request dispatcher for layout resource: true
                      2005-11-23 21:49:49,687 DEBUG [org.jboss.portal.server.theme.LayoutDispatcher] done with the layout

                      Everything works fine, and I can go through the application.

                      My struts app is ok, as I can access it directly using the URL pattern defined in the struts-config.xml.

                      I'm logging the 1st line of the execute method of the HelloAction class, but it doesn't show in the log. Therefore, this error prevents the bridge from calling my Action.

                      Alessandro Coelho Ribeiro
                      alessandro.ribeiro@integritas.com.br


                      • 8. Re: Problems with StrutsBridge
                        alessandroribeiro

                        I just went through a debugging session using the Demo application instead of my own, and I have one breakpoint in the JBossServletContextProvider:getServletContext method. In the demo application, when I execute this method, there is a BridgeInfo instance stored in the ThreadLocal variable.

                        So, I still don't know where I should be looking for bugs.

                        Tks,

                        Alessandro Coelho Ribeiro
                        alessandro.ribeiro@integritas.com.br

                        • 9. Re: Problems with StrutsBridge

                          and when you execute your portlet, is the thread local set or not like in the demo ?

                          • 10. Re: Problems with StrutsBridge
                            alessandroribeiro


                            In the demo, the ThreadLocal is set. In my portlet, it is not.

                            • 11. Re: Problems with StrutsBridge
                              alessandroribeiro

                              Hi,

                              does anyone have another example of using StrutsBridge other than the well-known demo. I would like the simplest possible example of a Struts action, redirecting to a static JSP page. I just need another example, so that I can compare it to my own and see what may be wrong.

                              Please, if you do have another example, send it to my email address bellow.

                              Thanks,

                              Alessandro Coelho Ribeiro
                              alessandro.ribeiro@integritas.com.br

                              • 12. Re: Problems with StrutsBridge
                                stamburini

                                I had the same problem- But with with config-name = 'StrutsPortlet' there are no problems !
                                The specific struts container configuration has not to be chenged ?

                                <portlet-app>

                                <portlet-name>MyPortlet</portlet-name>
                                <!-- Use the specific struts container configuration -->
                                <config-name>StrutsPortlet</config-name>

                                </portlet-app>

                                Silvano

                                • 13. Re: Problems with StrutsBridge
                                  stucairns

                                  I think you're missing the following line from your jboss_portlet.xml Just paste it in and all will work.... Hopefully ;)

                                  <config-name>StrutsPortlet</config-name>


                                  Stu.

                                  • 14. Re: Problems with StrutsBridge

                                     

                                    "alessandroribeiro" wrote:
                                    Hi,

                                    this is the demo's jboss-portlet.xml:

                                    <portlet-app>
                                    <portlet>
                                    <portlet-name>StrutsHelloPortlet</portlet-name>
                                    <!-- Use the specific struts container configuration -->
                                    <config-name>StrutsHelloPortlet</config-name>
                                    </portlet>
                                    </portlet-app>


                                    I had tried both with and without <config-name> to no avail. I tried to insert this line again in the file, but there is still this "no bridge set" error. And there is also a new error:

                                    21:15:23,703 ERROR [PortletAppDeployment] No config for the name StrutsHelloPortlet will use the default configuration

                                    What exactly is this <config-name> used for ?


                                    Hello,

                                    I want to get the ServletContext from portlet for some special reason. I am trying to use eclipse BIRT report engine in my ReportPortlet.

                                    But the BIRT report engine API need to access ServletContext. I went through the posts, and find the bridge is a way to get the ServletContext.

                                    But when i deploy my portlet and its init() method through the following exception



                                    Caused by: java.lang.IllegalStateException: No bridge set
                                    at org.jboss.portal.bridge.JBossServletContextProvider.getServletContext(JBossServletContextProvider.java:65)
                                    at com.ternary.wirelessthermometer.portlet.ReportPortlet.init(Unknown Source)
                                    at javax.portlet.GenericPortlet.init(GenericPortlet.java:355)
                                    at org.jboss.portal.portlet.PortletContainer.initPortlet(PortletContainer.java:368)
                                    at org.jboss.portal.portlet.PortletContainer.start(PortletContainer.java:229)


                                    I am using jbp2.2.1 on AS4.0.3SP1.

                                    In addition, what is the <config-name>StrutsHelloPortlet</config-name>
                                    for?

                                    yang