10 Replies Latest reply: Aug 22, 2011 3:02 AM by cooper lee RSS

    Problems with seam taglib

    Michael Weber Newbie

      Hi everybody,

       

      I'm quietly new to GateIn+JBoss PortletBrigde. I'm facing a problem when using the seam taglib to load dynamically graphic images in this way:

       

       

      <s:graphicImage value="/img/dyfa-water.png">
             <s:transformImageSize width="50" maintainRatio="true" />
      </s:graphicImage>
      

       

       

      Then I get the following error stack trace when the portlet is rendered:

       

       

      16:44:10,230 ERROR [[Seam Resource Servlet]] Servlet.service() for servlet Seam Resource Servlet threw exception

      java.lang.IllegalStateException: No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)

          at org.jboss.seam.contexts.PageContext.getPhaseId(PageContext.java:163)

          at org.jboss.seam.contexts.PageContext.isBeforeInvokeApplicationPhase(PageContext.java:175)

          at org.jboss.seam.contexts.PageContext.getCurrentWritableMap(PageContext.java:91)

          at org.jboss.seam.contexts.PageContext.remove(PageContext.java:105)

          at org.jboss.seam.Component.newInstance(Component.java:2167)

          at org.jboss.seam.Component.getInstance(Component.java:2024)

          at org.jboss.seam.Component.getInstance(Component.java:2003)

          at org.jboss.seam.Component.getInstance(Component.java:1997)

          at org.jboss.seam.Component.getInstance(Component.java:1970)

          at org.jboss.seam.Component.getInstance(Component.java:1965)

          at org.jboss.seam.faces.FacesPage.instance(FacesPage.java:92)

          at org.jboss.seam.core.ConversationPropagation.restorePageContextConversationId(ConversationPropagation.java:84)

          at org.jboss.seam.core.ConversationPropagation.restoreConversationId(ConversationPropagation.java:57)

          at org.jboss.seam.servlet.ContextualHttpServletRequest.restoreConversationId(ContextualHttpServletRequest.java:111)

          at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:55)

          at org.jboss.seam.ui.graphicImage.GraphicImageResource.getResource(GraphicImageResource.java:46)

          at org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80)

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)

          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

          at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

          at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:402)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

          at java.lang.Thread.run(Thread.java:662)

       

       

      Is there a possibility to solve this? Or is there a possibility to render images dynamically in another way? The goal is to load later images directly from the database, i.e. binary objects. Any help would be appreciated.

       

      Regards,

      Michael

        • 1. Problems with seam taglib
          Stefan Tausendpfund Novice

          Hi Michael,

           

          did you also try the a4j:mediaOutput of richfaces? This component enables you to display loaded images from a database.

          Here a link to the online demo:

          http://livedemo.exadel.com/richfaces-demo/richfaces/mediaOutput.jsf

          regards

            Stefan

          • 2. Problems with seam taglib
            Michael Weber Newbie

            Hi Stefan,

             

            thank you for your immedaite response. Your proposal worked to integrate dynamically images into my JSF. Anyway, the seam taglib does not work when using the portlet bridge. But using richfaces is an appropriate way arround.

             

            Thank you.

             

            Kind regards,

            Michael

            • 4. Re: Problems with seam taglib
              Michael Weber Newbie

              Hi Wesley,

               

              it's not only the graphic-tag, which does not work. It seems that the same bug appears when using <s:fileUpload/>. Is there another possibility to upload some files with Seam and Portlet Bridge? I also tried <rich:fileUpload/>, which causes the same error. Is there a way to handle PortletActionRequests and PortletResourceRequests directly with JBoss Portlet Bridge, because I really need to get the upload functionality running very soon?

               

              Here is once again the stacktrace:

               

              Caused by: javax.portlet.faces.BridgeException: Error processing resource lifecycle

                  at org.jboss.portletbridge.ExceptionHandlerBase.processResourceException(ExceptionHandlerBase.java:91)

                  at org.jboss.portletbridge.AjaxPortletBridge.doFacesRequest(AjaxPortletBridge.java:836)

                  at javax.portlet.faces.GenericFacesPortlet.serveResource(GenericFacesPortlet.java:541)

                  ... 134 more

              Caused by: javax.faces.FacesException: org.gatein.pc.portlet.impl.jsr168.api.ResourceRequestImpl cannot be cast to javax.servlet.ServletRequest

                  at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:86)

                  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)

                  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

                  at org.jboss.portletbridge.AjaxPortletBridge.execute(AjaxPortletBridge.java:1163)

                  at org.jboss.portletbridge.AjaxPortletBridge.doFacesRequest(AjaxPortletBridge.java:825)

                  ... 135 more

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

                  at org.jboss.seam.ui.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:65)

                  at org.jboss.seam.ui.util.cdk.RendererBase.decode(RendererBase.java:59)

                  at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)

                  at javax.faces.component.UIInput.decode(UIInput.java:725)

                  at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1031)

                  at javax.faces.component.UIInput.processDecodes(UIInput.java:639)

                  at javax.faces.component.UIForm.processDecodes(UIForm.java:209)

                  at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)

                  at org.richfaces.component.UISimpleTogglePanel.processDecodes(UISimpleTogglePanel.java:119)

                  at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)

                  at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:400)

                  at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:240)

                  at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:417)

                  at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)

                  ... 139 more

               

               

               

              Here is my JSF-Code:

               

              <h:form id="form" enctype="multipart/form-data">
                   <h3>Upload file</h3>
                          Select a picture for upload<br />
                   <s:fileUpload id="file" data="#{generalEmpActions.file}"
                               accept="image/jpeg" />
                   <rich:fileUpload
                       fileUploadListener="#{generalEmpActions.pictureUploadListener}"
                       maxFilesQuantity="1" id="pictureUpload" immediateUpload="#{true}"
                       acceptedTypes="jpg" allowFlash="#{false}">
                   <a:support event="onuploadcomplete" reRender="realPicture,anonymousPicture" />
                    </rich:fileUpload>
                   <a:commandButton id="show" action="#{searchEmpActions.showUpload()}" value="Go" reRender="realPicture,anonymousPicture"/>
              </h:form>
              

               

               

              And my code in the corresponding Bean for the uploadListener:

               

               

              public void pictureUploadListener(UploadEvent event) throws Exception {
                      UploadItem item = event.getUploadItem();
                      if(item == null)
                          log.error("This should not happen: UploadItem is null");
                      Document picture;
                      this.currentEmployee = new Employee();
                      if (this.currentEmployee.getPicture() != null)
                          picture = this.currentEmployee.getPicture();
                      else
                          picture = new Document();
                      if (item.getData().length > 5242880) {
                          facesMessages.addFromResourceBundle(Severity.ERROR,
                                  "com_dyfa_cip_session_filetoolarge", "5MB");
                          return;
                      }
                      picture.setSize((long) item.getData().length);
                      picture.setDocumentName("picture_new");
                      picture.setData(item.getData());
                      picture.setDescription("employee's picture");
                      picture.setContentType("image/jpeg");
                      picture.setChangedDate(Calendar.getInstance().getTime());
                      this.currentEmployee.setPicture(picture);
                      facesMessages.addFromResourceBundle(Severity.INFO,
                              "com_dyfa_cip_session_emp_pic_added");
                  }
              

               

               

              I hope, somebody can help me.

               

              Thanks in advance.

               

              Cheers,

              Michael

              • 5. Problems with seam taglib
                Stefan Tausendpfund Novice

                Hi Michael,

                 

                multipart requests are not handled for seam components. Remove the s:fileUpload inside the form then upload works fine. If you're using GateIn you will need to use the 2.1.0-SNAPSHOT release (actual svn trunk build). There is a bugfix PBR-212 included needed for Gatein portal.

                 

                 

                regards

                  Stefan

                • 6. Re: Problems with seam taglib
                  Michael Weber Newbie

                  Hello Stefan,

                   

                  and again you saved my day. Thank you very much. After building the portlet-bridge-snapshot from source everything works now as expected. One important information for displaying pictures which are stored in the database: Please look here http://community.jboss.org/docs/DOC-14811. This was also very useful.

                   

                  regards,

                  Michael

                  • 7. Re: Problems with seam taglib
                    cooper lee Newbie

                    need help

                     

                    i use rich:fileUpload  but fileUploadListener  is never called ,why

                     

                    i use portletBridge 2.1.0.FINAL

                    • 8. Re: Problems with seam taglib
                      cooper lee Newbie

                      portletBridge 2.1.0.FINAL is not work

                      i use svn checkout 2.1.2.GA.EPP51 now it's work

                      • 9. Re: Problems with seam taglib
                        Axayacatl Morales Newbie

                        Hi Cooper i cant find 2.1.2.GA.EPP51, can you help me