1 2 Previous Next 20 Replies Latest reply: May 9, 2012 2:14 PM by Ken Finnigan RSS

    Seam Messages

    Andre Pankraz Newbie

      Hello,

      i use Portletbridge 2 Snapshot with Seam 2.2.0 GA in JBoss Portal 2.7.2.

      Very often i see:

      11:37:53,090 ERROR [SeamExceptionHandlerImpl] Unable to process exception with Seam exception handler
      java.lang.ClassCastException: org.jboss.seam.faces.FacesMessages cannot be cast to org.jboss.portletbridge.seam.FacesMessages
       at org.jboss.portletbridge.seam.FacesMessages.instance(FacesMessages.java:91)
       at org.jboss.portletbridge.SeamExceptionHandlerImpl.handleException(SeamExceptionHandlerImpl.java:140)
       at org.jboss.portletbridge.SeamExceptionHandlerImpl.handleViewSetup(SeamExceptionHandlerImpl.java:93)
       at org.jboss.portletbridge.SeamExceptionHandlerImpl.processRenderException(SeamExceptionHandlerImpl.java:85)
       at org.jboss.portletbridge.AjaxPortletBridge.doFacesRequest(AjaxPortletBridge.java:665)
       at javax.portlet.faces.GenericFacesPortlet.doFacesDispatch(GenericFacesPortlet.java:598)
       at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:486)
       at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
       at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:457)
       at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
      


      Have i forgotten some configuration?


      Another problem is the usage of "%" as first character in an input field.

      Caused by: java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
       at java.net.URLDecoder.decode(URLDecoder.java:168)
       at org.jboss.portletbridge.context.PortalActionURL.decodeURL(PortalActionURL.java:100)
       at org.jboss.portletbridge.context.PortalActionURL.setQueryString(PortalActionURL.java:318)
       at org.jboss.portletbridge.context.PortalActionURL.<init>(PortalActionURL.java:93)
       at org.jboss.portletbridge.context.AbstractExternalContext.encodeActionURL(AbstractExternalContext.java:517)
       at org.jboss.seam.ui.util.ViewUrlBuilder.getEncodedUrl(ViewUrlBuilder.java:52)
       at org.jboss.seam.ui.component.UISeamCommandBase.getUrl(UISeamCommandBase.java:120)
       at org.jboss.seam.ui.renderkit.LinkRendererBase.doEncodeBegin(LinkRendererBase.java:26)
       at org.jboss.seam.ui.util.cdk.RendererBase.encodeBegin(RendererBase.java:79)
       at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:275)
       at org.richfaces.renderkit.AbstractTableRenderer.encodeHeaderFacets(AbstractTableRenderer.java:299)
       at org.richfaces.renderkit.AbstractTableRenderer.encodeHeader(AbstractTableRenderer.java:192)
       at org.richfaces.renderkit.AbstractTableRenderer.encodeTableStructure(AbstractTableRenderer.java:159)
       at org.richfaces.renderkit.html.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:160)
       at org.richfaces.renderkit.html.DataTableRenderer.doEncodeBegin(DataTableRenderer.java:148)
       at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:100)
       at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
       at javax.faces.component.UIData.encodeBegin(UIData.java:962)
       at org.ajax4jsf.component.UIDataAdaptor.encodeBegin(UIDataAdaptor.java:1202)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:275)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
       at org.jboss.portletbridge.lifecycle.RenderResponsePhase.executePhase(RenderResponsePhase.java:58)
       at org.jboss.portletbridge.lifecycle.LifecyclePhase.execute(LifecyclePhase.java:72)
       ... 236 more
      


      Any ideas?

      Best regards,
      André

        • 1. Re: Seam Messages
          Andre Pankraz Newbie

          Another cast problem with seam-debug debug.xhtml:

          15:18:51,958 ERROR [LifecyclePhase] Error to execute beforePhase RENDER_RESPONSE 6 method for listener
          java.lang.ClassCastException: org.jboss.portletbridge.richfaces.BufferedRenderResponseWrapper cannot be cast to javax.servlet.http.HttpServletResponse
           at org.jboss.seam.debug.jsf.SeamDebugPhaseListener.beforePhase(SeamDebugPhaseListener.java:48)
           at org.jboss.portletbridge.lifecycle.LifecyclePhase.execute(LifecyclePhase.java:65)
           at org.jboss.portletbridge.lifecycle.PortletLifecycle.render(PortletLifecycle.java:155)
          


          • 2. Re: Seam Messages
            Andre Pankraz Newbie

            And another problem...org.jboss.portletbridge.richfaces.resource.PortletScriptRenderer:

             String scriptId = context.getPathInfo();
             OutputStream out = context.getOutputStream();
             scriptId = scriptId.substring(scriptId.lastIndexOf("/") + 1);
            


            context is PortletRessourceContext, which delivers:
             public String getPathInfo() {
             return null;//request.getPathInfo();
             }
            


            so we get NullPointer by default.


            Hmmm...problem overload ;)

            • 3. Re: Seam Messages
              Andre Pankraz Newbie

              short update to first of 4 problems so far...

              there is a file seam.properties missing in portletbridge-impl.jar (include empty one under src/main/ressource).

              without this the following component is never injected:

              package org.jboss.portletbridge.seam;
               ...
              
              import javax.faces.application.FacesMessage;
              import java.util.ArrayList;
              import java.util.Iterator;
              import java.util.List;
              
              /**
               * @author Joseph Berdat
               */
              
              @SuppressWarnings("serial")
              @Scope(ScopeType.CONVERSATION)
              @Name(StatusMessages.COMPONENT_NAME)
              @Install(precedence=DEPLOYMENT, classDependencies="javax.faces.context.FacesContext")
              @BypassInterceptors
              public class FacesMessages extends org.jboss.seam.faces.FacesMessages {
              



              now we get:

              16:48:10,521 INFO [Component] Component: org.jboss.seam.international.statusMessages, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.portletbridge.seam.FacesMessages


              and no more class cast exceptions.

              • 4. Re: Seam Messages
                Alexander Smirnov Master

                Thank your for deep investigation, it is very helpful. I already fixed ExceptionHandler for Seam, with your advise.
                The problem with invalid characters in s:link and s:button parameters is much deeper. I recently fixed URL parameters encoding/decoding in the bridge but that breaks the old workaround for the same issue in Seam code. I afraid it is not possible to fix that issue without compatibility problems, sorry.
                PortletScriptRenderer is going to be moved from separate project into bridge-impl because bridge itself needs a custom resource manager that renders resources URL's as portlet ResourceURL.

                • 5. Re: Seam Messages
                  Andre Pankraz Newbie

                  Thx,

                  good work!

                  concerning the trailing "%" problem:

                  The problem only occurs in the render phase and not in "processAction" phase -> handleNavigation() -> decodeUrl(), because there % is encoded as %25 as necessary.

                  In the render phase a link is created:

                  HtmlLink.getUrl() -> ViewUrlBuilder.getEncodedUrl() -> RenderPortletExternalContextImpl.encodeActionUrl() -> PortalActionURL. -> PortalActionURL.setQueryString() -> decodeUrl() ????

                  Why decodeUrl() is called in the encodeActionUrl phase? Shouldn't this be encodeUrl? The input parameter is % here and this is the problem.


                  Best regards,
                  André

                  • 6. Re: Seam Messages
                    Andre Pankraz Newbie

                    decode is OK...problem is, the function
                    AbstractExternalContext.encodeActionUrl()
                    is called with encoded url parameters in action phase and without url encoded parameters for link creation in render phase.

                    in seam-ui 2.2.0 in UISeamCommandBase we find:
                    ViewUrlBuilder url = new ViewUrlBuilder(viewId, getFragment(), !isPortletRequest(getFacesContext()));


                    so this is intended behaviour in portlet environment...very strange to me, without this addition in seam-ui this stuff would work?! what was the intention? ok the seam guys know...


                    or should it be the other way around and the action phase should have decoded the url parameters before the callout to AbstractExternalContext.encodeActionUrl()?


                    One or the other way has to be the correct one and i have no problems patching the code for our environment because this is a show stopper (under many, see Seam context problem...). I cannot say to the customer, sry...don't use %, all is OK.


                    Best regards,
                    André

                    • 7. Re: Seam Messages
                      Alexander Smirnov Master

                      That is problem in the Seam s:link and s:button renderer base class UISeamCommandBase has been inspired by me far ago ( sorry about my mistake ) as incorrect fix for portlet environment. Because I fixed encoding in bridge, the old workaround becomes a problem.
                      removing that check form Seam code could inspire a versions incompatibility mess.
                      We can provide custom version of seam command renderer with Bridge 2.0 release. The other idea seems like as ugly hack, but it may work: isPortletRequest relays on static field with PortletRequest class so Bridge could use reflection to clear that field and return Seam command renderer to encoding parameter values in all request types.

                      • 8. Re: Seam Messages
                        Alexander Smirnov Master

                        Good news: the problem with ScriptRenderer has been resolved.

                        • 9. Re: Seam Messages
                          Andre Pankraz Newbie

                          thx, really thx,

                          great work!
                          thx for clarification, with the hints i can patch it myself and later integrate the final solution (patching seam-ui class or your reflection hint or adding phase-isrenderphase check in bridge encodeURL or something like that)


                          i have allready checked the script renderer stuff (fisheye RSS is nice).
                          No exceptions, running fine.

                          I have a strange problem though. After my Conversation Context Fix (see ejb-transaction thread) i can run seam-gen app portlets.

                          They use Richfaces and i have copied your updated settings out of the example (see web.xml attached).


                          I get 8 Requests for the single seam-gen List-Portlet.
                          Main request: http://localhost:8080/portal/portal/default/IFOS+Fachadmin
                          Following:
                          404: http://localhost:8080/ifosApp/faces/rfRes/org/ajax4jsf/framework.pack.js
                          404: http://localhost:8080/ifosApp/faces/rfRes/org/richfaces/ui.pack.js
                          200, CSS OK: http://localhost:8080/portal/portal/default/IFOS+Fachadmin/blogPortletWindow?id=%2Fstylesheet%2Ftheme.css&action=f&cacheability=PAGE
                          200, is Login Page, dont know why: http://localhost:8080/portal/auth/portal/default/IFOS+Fachadmin
                          200, but is full HTML page, not an image: http://localhost:8080/portal/portal/default/IFOS+Fachadmin/blogPortletWindow?rfRes=org.richfaces.renderkit.html.GradientA&action=b&cacheability=PAGE&DATA=%2FB%2FeAH7%21%213Tj2v7mAAZZAV3
                          200, but is full html page not an image: http://localhost:8080/portal/portal/default/IFOS+Fachadmin/blogPortletWindow?rfRes=org.richfaces.renderkit.html.images.SliderFieldGradient&action=b&cacheability=PAGE&DATA=%2FB%2FeAH79-XN%21%21%21%21mQAaRgXe
                          200, but is full html page, not an image: http://localhost:8080/portal/portal/default/IFOS+Fachadmin/blogPortletWindow?rfRes=org.richfaces.renderkit.images.TabGradientB&action=b&cacheability=PAGE&DATA=%2FB%2FeAH7%21%21%21%21%213vHmAAaGQWj


                          The portlet page is rendered 4 times, because the gradient images are also rendered as full portal HTML pages (4 full requests with SQL selects).
                          If i run the app out of portlet environment, and check the image links, i get gradient images.
                          e.g.: http://localhost:8080/ifosApp/rfResorg.richfaces.renderkit.html.images.SliderFieldGradient/DATB/eAH79-XN!!!!mQAaRgXe.xhtml
                          if i run in the portlet environment, i get 4 page requests and no images.

                          i have updatet to the today svn code...strange.

                          <?xml version="1.0" encoding="UTF-8"?>
                          <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                           <display-name>IFOS</display-name>
                           <description>IFOS - Interaktiven FOrtbildungsSystem fuer die BUNDesverwaltung</description>
                           <!-- Ajax4jsf -->
                           <context-param>
                           <param-name>org.jboss.portletbridge.WRAP_SCRIPTS</param-name>
                           <param-value>true</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.jboss.portletbridge.ExceptionHandler</param-name>
                           <param-value>org.jboss.portletbridge.SeamExceptionHandlerImpl</param-value>
                           </context-param>
                           <context-param>
                           <param-name>javax.faces.LIFECYCLE_ID</param-name>
                           <param-value>SEAM_PORTLET</param-value>
                           </context-param>
                          
                           <context-param>
                           <param-name>javax.portlet.faces.RENDER_POLICY</param-name>
                           <param-value>ALWAYS_DELEGATE</param-value>
                           </context-param>
                           <context-param>
                           <param-name>javax.portlet.faces.preserveActionParams</param-name>
                           <param-value>true</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.ajax4jsf.RESOURCE_URI_PREFIX</param-name>
                           <param-value>rfRes</param-value>
                           </context-param>
                           <!--
                           <context-param>
                           <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
                           <param-value>false</param-value>
                           </context-param>
                           -->
                           <context-param>
                           <param-name>org.richfaces.SKIN</param-name>
                           <param-value>blueSky</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.richfaces.LoadStyleStrategy</param-name>
                           <param-value>DEFAULT</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.richfaces.LoadScriptStrategy</param-name>
                           <param-value>ALL</param-value>
                           </context-param>
                           <!-- Facelets development mode (disable in production) -->
                           <context-param>
                           <param-name>facelets.DEVELOPMENT</param-name>
                           <param-value>true</param-value>
                           </context-param>
                          
                           <!-- JSF -->
                           <context-param>
                           <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                           <param-value>.xhtml</param-value>
                           </context-param>
                           <context-param>
                           <param-name>facelets.VIEW_MAPPINGS</param-name>
                           <param-value>*.xhtml</param-value>
                           </context-param>
                          
                           <filter>
                           <filter-name>Seam Filter</filter-name>
                           <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
                           </filter>
                           <filter-mapping>
                           <filter-name>Seam Filter</filter-name>
                           <servlet-name>Faces Servlet</servlet-name>
                           <dispatcher>FORWARD</dispatcher>
                           <dispatcher>REQUEST</dispatcher>
                           <dispatcher>INCLUDE</dispatcher>
                           </filter-mapping>
                           <listener>
                           <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
                           </listener>
                           <servlet>
                           <servlet-name>Seam Resource Servlet</servlet-name>
                           <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
                           </servlet>
                           <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>Seam Resource Servlet</servlet-name>
                           <url-pattern>/seam/resource/*</url-pattern>
                           </servlet-mapping>
                           <servlet-mapping>
                           <servlet-name>Faces Servlet</servlet-name>
                           <url-pattern>*.xhtml</url-pattern>
                           </servlet-mapping>
                           <session-config>
                           <!--
                           in minutes, less than the SFSB timeout, default is 30 minutes in
                           jboss, see comments to standardjboss.xml / max-bean-life in seam
                           reference documentation
                           -->
                           <session-timeout>29</session-timeout>
                           </session-config>
                           <security-constraint>
                           <!--
                           prevent download of Seam's "*.page.xml", cannot restrict less than
                           "*.xml", siehe auch "Arten von Pattern" unter
                           https://wiki.imise.uni-leipzig.de/Themen/WebApp/WebXml
                           -->
                           <web-resource-collection>
                           <web-resource-name>no_access</web-resource-name>
                           <url-pattern>*.xml</url-pattern>
                           </web-resource-collection>
                           <auth-constraint />
                           </security-constraint>
                           <login-config>
                           <auth-method>BASIC</auth-method>
                           </login-config>
                          </web-app>
                          


                          • 10. Re: Seam Messages
                            Andre Pankraz Newbie

                            gradient images are working with the today version, for instance

                            http://localhost:8080/portal/portal/default/IFOS+Fachadmin/blogPortletWindow?rfRes=org.richfaces.renderkit.html.GradientA&action=b&cacheability=PAGE&DATA=%2FB%2FeAH7%21%213Tj2v7mAAZZAV3

                            is really a gradient image now, only one backend page request.

                            thx a lot!


                            only the lines



                            in jboss_portlet for seamBookingPortlet should be checked, i get 404 for this ressources...like expected.

                            • 11. Re: Seam Messages
                              Andre Pankraz Newbie

                              I have found out the problem with resource links like:

                              - /ifosApp/faces/rfResorg/richfaces/renderkit/html/css/basic_both.xcss
                              - /ifosApp/faces/rfRes/org/ajax4jsf/framework.pack.js

                              they where all invalid (404) for my web application.

                              According to Seam docu 30.1.4.6 Seam includes Ajax4jfs filter. But this doesn't work for Resource Requests, even if the Seam Servlet delivers /faces/*.

                              So i included the ajax4jsf config only for delivering these resources, seam includes ajax4jfs for the remaining tasks by itself:

                              &lt;filter>
                              &lt;display-name>Ajax4jsf Filter&lt;/display-name>
                              &lt;filter-name>ajax4jsf&lt;/filter-name>
                              &lt;filter-class>org.ajax4jsf.Filter&lt;/filter-class>
                              &lt;/filter>
                              &lt;filter-mapping>
                              &lt;filter-name>ajax4jsf&lt;/filter-name>
                              &lt;url-pattern>/faces/*&lt;/url-pattern>
                              &lt;dispatcher>FORWARD&lt;/dispatcher>
                              &lt;dispatcher>REQUEST&lt;/dispatcher>
                              &lt;dispatcher>INCLUDE&lt;/dispatcher>
                              &lt;/filter-mapping>

                              context-param:
                              org.ajax4jsf.RESOURCE_URI_PREFIX -> rfRes (like in example)



                              Small additional hint:

                              seamBooking example "import.sql" includes datasets like this:

                              insert into Hotel (id, price, name, address, city, state, zip, country) values (20, 250, 'Meliá White House', 'Albany Street', 'Regents Park London', '', 'NW13UP', 'Great Britain')

                              Oracle considers empty strings '' as null.

                              you should uncomment NotNull in Hotel.java:

                              @Length(min=2, max=10) // @NotNull
                              public String getState()
                              {
                              return state;
                              }

                              • 12. Re: Seam Messages
                                Andre Pankraz Newbie

                                Hi,


                                more tests...

                                Seam Filters doesn't work with your Seam settings, maybe thats the reason why ajax4jsf Filter isn't installed correctly through Seam (see above) e.g. following test is never called in portlet mode.:

                                package de.init.bakoev.ifos.app.util;
                                
                                import java.io.IOException;
                                
                                import javax.servlet.FilterChain;
                                import javax.servlet.ServletException;
                                import javax.servlet.ServletRequest;
                                import javax.servlet.ServletResponse;
                                
                                import org.jboss.seam.ScopeType;
                                import org.jboss.seam.annotations.Name;
                                import org.jboss.seam.annotations.Scope;
                                import org.jboss.seam.annotations.Startup;
                                import org.jboss.seam.annotations.intercept.BypassInterceptors;
                                import org.jboss.seam.web.AbstractFilter;
                                
                                @Startup
                                @Scope(ScopeType.APPLICATION)
                                @Name("standaloneFilter")
                                @BypassInterceptors
                                // @Filter(within = "org.jboss.seam.web.ajax4jsfFilter")
                                public class StandaloneFilter extends AbstractFilter {
                                
                                 @Override
                                 public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
                                 final FilterChain filterChain) throws IOException, ServletException {
                                 System.out.println("###FILTER!");
                                 filterChain.doFilter(servletRequest, servletResponse);
                                 }
                                
                                }
                                


                                Quite severe bug?


                                Minor Bug:

                                Seam Captcha doesn't work in portlet mode, seems the answer changes over process-request or some caching problem:
                                <h:inputText id="verifyCaptcha" required="true"
                                 value="#{captcha.response}" />
                                <h:message for="verifyCaptcha" />
                                



                                Another iInteresting Bug:

                                I have 3 Portlets on one Page, than i get too deep recursion javascript probleme if i load the richfaces js three times (like your example template does):
                                line 3165 in framework.pack.js:
                                }else{if(LOG._onkeydown){LOG._onkeydown(G)


                                you shouldn't place this stuff into the portlets, even for GateIn.


                                Best regards,
                                Andre

                                • 13. Re: Seam Messages
                                  Andre Pankraz Newbie

                                  to the last problem, the richfaces seam portlets are crazy slow if i have multiple portlets on a page. (inputText fields)

                                  IE even shows out of mem, firefox is very slow.

                                  has nothing to do with loading js once or multiple times, even only loading it once results in very laggy inputText fields.


                                  no ajax4jsf stuff used...a simple
                                  <h:inputText id="nutzername" required="true"
                                  value="#{nutzer.nutzername}" />

                                  • 14. Re: Seam Messages
                                    Andre Pankraz Newbie

                                    forget the js problems, the problem was multiple
                                    <a:log hotkey="D" />
                                    in each portlet one, resulting in the -> too deep recursion


                                    the other 2 problems remain, no seam filters called and seam captchas not working

                                    1 2 Previous Next