11 Replies Latest reply on Jun 11, 2013 9:56 AM by Ken Finnigan

    Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0

    Marc Ende Newbie

      Hi,

       

      after the availability of portletbridge 3.0.0 I decided to play around with the portlet bridge and JSF 2.0 in JBoss 7. But the following stacktrace occured when

      I tried to access the page with the portlet.

       

      java.lang.IllegalStateException: Must call associate() before calling activate()
      at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:200)
      at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:108)
      at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)
      at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
      at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderFaces(Jsf20ControllerImpl.java:368)
      at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderPortletBody(Jsf20ControllerImpl.java:252)
      at org.jboss.portletbridge.PortletBridgeImpl.doFacesRequest(PortletBridgeImpl.java:257)
      at javax.portlet.faces.GenericFacesPortlet.doFacesDispatch(GenericFacesPortlet.java:515)
      at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:436)
      at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
      at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:410)
      [...]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
      at java.lang.Thread.run(Thread.java:722)

       

      I'm using this web.xml:

      {code}

      <?xml version="1.0"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xmlns="http://java.sun.com/xml/ns/javaee"

          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

          version="2.5">



          <display-name>Archetype Created Web Application</display-name>

          <context-param>

                   <param-name>javax.portlet.faces.RENDER_POLICY</param-name>

                   <param-value>ALWAYS_DELEGATE</param-value>

              </context-param>

              <context-param>

                   <param-name>javax.faces.FACELETS_LIBRARIES</param-name>

                   <param-value>/WEB-INF/app-tags.taglib.xml</param-value>

              </context-param>

              <context-param>

                   <param-name>javax.faces.PROJECT_STAGE</param-name>

                   <param-value>Development</param-value>

              </context-param>

              <context-param>

                   <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

                   <param-value>server</param-value>

              </context-param>


              <servlet>

                   <servlet-name>Faces Servlet</servlet-name>

                   <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                   <load-on-startup>1</load-on-startup>

              </servlet>

              <servlet-mapping>

                   <servlet-name>Faces Servlet</servlet-name>

                   <url-pattern>*.jsf</url-pattern>

              </servlet-mapping>

              <servlet-mapping>

                   <servlet-name>Faces Servlet</servlet-name>

                   <url-pattern>/faces/*</url-pattern>

              </servlet-mapping>



              <mime-mapping>

                   <extension>xcss</extension>

                   <mime-type>text/css</mime-type>

              </mime-mapping>




      </web-app>

       

       

      And this portlet.xml:

       

      <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd

                                               http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"

                   version="2.0">

          <portlet>

              <portlet-name>Test</portlet-name>

              <portlet-class>

                  javax.portlet.faces.GenericFacesPortlet

              </portlet-class>

              <init-param>

                  <name>javax.portlet.faces.defaultViewId.view</name>

                  <value>/index.xhtml</value>

              </init-param>

              <init-param>

                  <name>javax.portlet.faces.preserveActionParams</name>

                  <value>true</value>

              </init-param>

              <expiration-cache>0</expiration-cache>

              <supports>

                  <mime-type>text/html</mime-type>

              </supports>

              <portlet-info>

                  <title>Simplest Hello World Portlet</title>

              </portlet-info>

              <container-runtime-option>

                  <name>org.gatein.pc.remotable</name>

                  <value>true</value>

              </container-runtime-option>

          </portlet>

      </portlet-app>

       

      The index.xhtml is a stupid plain jsf 2.0 page:

      <?xml version='1.0' encoding='UTF-8' ?>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml"

            xmlns:h="http://java.sun.com/jsf/html"

            xmlns:p="http://primefaces.org/ui"

            xmlns:m="http://metawidget.org/faces">

        <h:head>

          <title>Facelet Title</title>

        </h:head>

        <h:body>

             <h1>hello world</h1>

        

        </h:body>

      </html>

       

      Does anybody have an idea?

       

      Thanks in advance

       

      Marc

        • 1. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
          Ken Finnigan Master

          Marc,

           

          From the stacktrace I can see that Weld in AS7 is being called.

           

          Does your archive contain a beans.xml and use CDI?

           

          If so, this currently will not work for a JSF2 portlet with the Portlet Bridge.

           

          There are some fixes that need to be implemented in Weld before CDI in a portlet will work.

           

          Regards

          Ken

          • 2. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
            Marc Ende Newbie

            Ken,

             

            great that fixes the portlet. Now it's running. I had expected that CDI in this constellation would work...

             

            Thanks!

            marc

            • 3. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
              Ken Finnigan Master

              Marc,

               

              CDI, and in this case Weld, are specifically built around the Servlet model.

               

              So there need to be some fixes made for it to work nicely in a Portlet model.

               

              These fixes are certainly part of our current tasks, but at this stage I don't have a schedule for when they would be completed or available.

               

              Ken

              • 4. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                sheriman xavier Newbie

                Hi ken,

                 

                I have same error like Marc Ende, i using GateIn-3.5.0.Final-jbossas7, Seam 2.3.0.Final , PortletBridge 3.2.0.Final and Jsf 2.1,

                 

                after started the gatein jboss server, and go to home page. i got this error:

                 

                Caused by: javax.portlet.faces.BridgeException: javax.faces.FacesException: Must call associate() before calling activate()

                        at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.throwBridgeException(Jsf20ControllerImpl.java:651)

                        at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderPortletBody(Jsf20ControllerImpl.java:255)

                        at org.jboss.portletbridge.PortletBridgeImpl.doFacesRequest(PortletBridgeImpl.java:258)

                        at javax.portlet.faces.GenericFacesPortlet.doFacesDispatch(GenericFacesPortlet.java:516)

                        ... 298 more

                Caused by: javax.faces.FacesException: Must call associate() before calling activate()

                        at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:142) [jsf-impl-2.1.7-jbossorg-2.jar:]

                        at org.jboss.portletbridge.context.exception.PortletExceptionHandler.handle(PortletExceptionHandler.java:95)

                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]

                        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]

                        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

                        at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderFaces(Jsf20ControllerImpl.java:369)

                        at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderPortletBody(Jsf20ControllerImpl.java:253)

                        ... 300 more

                Caused by: java.lang.IllegalStateException: Must call associate() before calling activate()

                        at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:200)

                        at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:108)

                        at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)

                        at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228) [jsf-impl-2.1.7-jbossorg-2.jar:]

                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) [jsf-impl-2.1.7-jbossorg-2.jar:]

                        ... 304 more

                 

                 

                 

                how can i solve this issues?

                • 5. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                  Ken Finnigan Master

                  Are you using CDI as well as Seam 2.3 and JSF 2.1?

                   

                  According to your stacktrace you are but you don't mention it in the post.

                   

                  If you don't mean to be using CDI, then remove all beans.xml files from your deployment.

                   

                  If you do want to use CDI in a JSF portlet, then follow the instructions here: https://docs.jboss.org/author/display/PBR32/CDI+Portlet+Development

                  • 6. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                    sheriman xavier Newbie

                    Thanks For Reply Ken,

                     

                    I am using CDI for switchyard Bean Injection and Seam for all the other transaction,

                     

                    so i want to use both, as you mentioned , i removed all the beans.xml, now all seam based screens are working but switchyard not working.

                    If i keep beans.xml then switchyard is working but seam based screens not working,

                     

                    i am getting the following Exception if i keep Beans.xml , when i click save button in seam based screens.

                     

                           

                    ... 198 more

                    Caused by: javax.portlet.faces.BridgeException: javax.faces.FacesException: org.gatein.pc.portlet.impl.jsr168.api.RenderRequestImpl cannot be cast to javax.servlet.http.H

                            at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.throwBridgeException(Jsf20ControllerImpl.java:651)

                            at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderPortletBody(Jsf20ControllerImpl.java:255)

                            at org.jboss.portletbridge.PortletBridgeImpl.doFacesRequest(PortletBridgeImpl.java:258)

                            at javax.portlet.faces.GenericFacesPortlet.doFacesDispatch(GenericFacesPortlet.java:516)

                            ... 262 more

                    Caused by: javax.faces.FacesException: org.gatein.pc.portlet.impl.jsr168.api.RenderRequestImpl cannot be cast to javax.servlet.http.HttpServletRequest

                            at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:142) [jsf-impl-2.1.7-jbossorg-2.jar:]

                            at org.jboss.portletbridge.context.exception.PortletExceptionHandler.handle(PortletExceptionHandler.java:95)

                            at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]

                            at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.7-jbossorg-2.jar:]

                            at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

                            at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderFaces(Jsf20ControllerImpl.java:369)

                            at org.jboss.portletbridge.bridge.controller.Jsf20ControllerImpl.renderPortletBody(Jsf20ControllerImpl.java:253)

                            ... 264 more

                    Caused by: java.lang.ClassCastException: org.gatein.pc.portlet.impl.jsr168.api.RenderRequestImpl cannot be cast to javax.servlet.http.HttpServletRequest

                            at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:115)

                            at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)

                            at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228) [jsf-impl-2.1.7-jbossorg-2.jar:]

                            at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) [jsf-impl-2.1.7-jbossorg-2.jar:]

                            ... 268 more

                     

                     

                     

                     

                     

                    can you give some idea how can i use both seam as well as CDI in GateIn portal.

                    i am stick on this issue for last two days....

                     

                    Thanks in advance.

                    • 7. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                      Ken Finnigan Master

                      I can't guarantee that Seam 2 and CDI will work together in a portlet, as its not something I've ever done.

                       

                      If you follow the directions about using CDI in a JSF portlet, from the link in the previous post, then CDI should work.

                      • 8. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                        sheriman xavier Newbie

                        Thanks Ken ,

                         

                        one more question, is it possible inject the bean using Seam2 instead of CDI? for switchyard service.

                         

                        i am using like this in my class

                        @Inject @Reference("MyService")

                            private MyService _myService;

                        is ther any way to replace the code in seam, so that i will drop the CDI from my applicaton in order to work Seam based screens.

                        • 9. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                          Ken Finnigan Master

                          I'm pretty sure Switchyard will only work with CDI, not Seam 2 injection, but you'd need to speak with Switchyard to confirm

                          • 10. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                            sheriman xavier Newbie

                            ohh big draw back ...i will speak with switchyard people.

                             

                            if switchyard will work only in cdi then can i  convert all my seam based transaction screen into CDI based Transaction screen ...can i do like that?

                            then i can drop Seam from my application what is your suggestion on this.

                            • 11. Re: Must call associate() before calling activate() GateIn 3.4.0/AS7 & PortletBridge 3.0.0
                              Ken Finnigan Master

                              If you want to remove Seam completely, then I believe you'd need to switch them all to use CDI instead.