13 Replies Latest reply on Jan 18, 2009 12:24 AM by Norman Richards

    how to debug seam url rewrite

    Dean Hiller Expert

      I only see these two logs in my console....



      Jan 15, 2009 11:36:39 PM org.jboss.seam.Component <init>
      INFO: Component: org.jboss.seam.web.rewriteFilter, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.web.RewriteFilter
      Jan 15, 2009 11:36:44 PM org.jboss.seam.servlet.SeamFilter init
      INFO: Initializing filter: org.jboss.seam.web.rewriteFilter



      I have the following page...


           <page view-id="/web/application.xhtml">
                <rewrite pattern="/appl/{app}"/>
                <rewrite pattern="/appl"/>
                
                <param name="app" value="#{buyApplication.app}" required="true"/>
                <action execute="#{buyApplication.loadApp()}"/>
               <navigation from-action="#{buyApplication.buyApp()}">
                    <redirect view-id="/secure/shop/licenses.xhtml"></redirect>
               </navigation>
               <navigation from-action="#{buyApplication.tryApp()}">
                    <redirect view-id="/secure/shop/free.xhtml"></redirect>
               </navigation>              
           </page>



      But when I go to localhost:8080/mainapp/appl/requirements


      I see no logs and it doesn't work?  How to debug this further?  are there any url rewrite filter logs?


      thanks,
      Dean

        • 1. Re: how to debug seam url rewrite
          Dean Hiller Expert

          weird, I added a rewrite pattern and now see a little error logs when I go to that url....



          Jan 15, 2009 11:50:04 PM org.jboss.seam.web.RewriteFilter getAllPatterns
          WARNING: Pages is null for incoming request!
          



          Here is my page I just added a pattern too.....



              <page view-id="/web/applications.xhtml">
                   <rewrite pattern="/applications"/>
                   <navigation from-action="#{buyApplication.buyIt(app)}">
                        <redirect view-id="/secure/shop/licenses.xhtml"></redirect>
                   </navigation>
                   <navigation from-action="#{buyApplication.tryIt(app)}">
                        <redirect view-id="/secure/shop/free.xhtml"></redirect>
                   </navigation>     
              </page>



          what is going on?

          • 2. Re: how to debug seam url rewrite
            Dean Hiller Expert

            I am stepping through the filter here...does this have somehting to do with that I have multiple pages.xxx.xml files and not a pages.xml file????  hmmmmmmmm....anyone know?

            • 3. Re: how to debug seam url rewrite
              Dean Hiller Expert

              nope, that is not it....man, why is my pages null in the filter..this is so weird.

              • 4. Re: how to debug seam url rewrite
                Dean Hiller Expert

                here is my components.xml file which doens't work.....



                <?xml version="1.0" encoding="UTF-8"?>
                <components xmlns="http://jboss.com/products/seam/components"
                            xmlns:core="http://jboss.com/products/seam/core"
                            xmlns:persistence="http://jboss.com/products/seam/persistence"
                            xmlns:transaction="http://jboss.com/products/seam/transaction"
                            xmlns:security="http://jboss.com/products/seam/security"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:mail="http://jboss.com/products/seam/mail"
                            xmlns:web="http://jboss.com/products/seam/web"  
                            xmlns:navigation="http://jboss.com/products/seam/navigation"
                            xsi:schemaLocation=
                                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                                 http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd 
                                 http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd 
                                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
                                 http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
                                 http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
                                 http://jboss.com/products/seam/navigation http://jboss.com/products/seam/navigation-2.0.xsd">
                
                     <core:init debug="true"/>
                    <core:manager conversation-timeout="120000" 
                                  concurrent-request-timeout="500"
                                  conversation-id-parameter="cid"/>
                
                              
                    <transaction:entity-transaction entity-manager="#{mgr}"/>
                
                    <persistence:entity-manager-factory name="saasplatform"/>
                    
                    <persistence:managed-persistence-context name="mgr"
                                               auto-create="true" 
                                    entity-manager-factory="#{saasplatform}"/>
                
                     <mail:mail-session ssl="false" tls="false" host="mail.authsmtp.com" port="2525" username="ac37612" password="depm6ebjp" />
                    <security:identity authenticate-method="#{login.authenticate}"/>  
                    
                    <event type="org.jboss.seam.security.notLoggedIn">
                          <action execute="#{redirect.captureCurrentView}"/>
                     </event>
                     <event type="org.jboss.seam.security.postAuthenticate">
                          <action execute="#{redirect.returnToCapturedView}"/>
                     </event>
                
                     <navigation:pages>
                         <navigation:resources>
                             <value>/WEB-INF/pages.global.xml</value>
                             <value>/WEB-INF/pages.public.xml</value>
                             <value>/WEB-INF/pages.user.xml</value>
                             <value>/WEB-INF/pages.ouradmin.xml</value>
                         </navigation:resources>
                     </navigation:pages>          
                     
                     <web:rewrite-filter view-mapping="*.xhtml"/>
                     
                </components>


                • 5. Re: how to debug seam url rewrite
                  Evgeny Denisov Newbie

                  at least current Seam documentation says about configuring web:rewrite-filter with


                  view-mapping="*.seam"




                  may be this is a problem

                  • 6. Re: how to debug seam url rewrite
                    Dean Hiller Expert

                    I am pretty sure that is not it(85%) sure and I hope not as it is a lot of work.  I looked at the code of the Seam RewriteFilter and if that attribute is not specified, it is set to .seam and if it is, it is set the my pattern of .xhtml.


                    Looking at the code, the problem is that the Pages object is plainly not in the ServletContext and it gets null which is why I get the Pages is null for incoming request except that it is null for every incoming request!!!!  Anyone know when the Pages is stuffed into the ServletContext so I can see why mine is not being put there????  (I am pretty sure that has nothing to do with the view-mapping settings)


                    thanks,
                    Dean

                    • 7. Re: how to debug seam url rewrite
                      Norman Richards Expert

                      What are your servlet mappings in web.xml?

                      • 8. Re: how to debug seam url rewrite
                        Dean Hiller Expert

                        Here they are...



                        <?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">
                        
                             <!-- Seam -->
                        
                             <listener>
                                  <listener-class>
                                       org.jboss.seam.servlet.SeamListener
                                  </listener-class>
                             </listener>
                        
                             <filter>
                                  <filter-name>UrlRewriteFilter</filter-name>
                                  <filter-class>
                                       org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
                                  </filter-class>
                        
                                  <!--  init-param>
                                       <param-name>logLevel</param-name>
                                       <param-value>DEBUG</param-value>
                                       </init-param-->
                        
                                  <init-param>
                                       <param-name>statusEnabled</param-name>
                                       <param-value>true</param-value>
                                  </init-param>
                        
                                  <init-param>
                                       <param-name>statusPath</param-name>
                                       <param-value>/url.status</param-value>
                                  </init-param>
                        
                             </filter>
                        
                             <filter-mapping>
                                  <filter-name>UrlRewriteFilter</filter-name>
                                  <url-pattern>/*</url-pattern>
                             </filter-mapping>
                        
                             <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>
                                  <url-pattern>/*</url-pattern>
                             </filter-mapping>
                        
                             <servlet>
                                  <servlet-name>Seam Resource Servlet</servlet-name>
                                  <servlet-class>
                                       org.jboss.seam.servlet.SeamResourceServlet
                                  </servlet-class>
                             </servlet>
                        
                             <servlet-mapping>
                                  <servlet-name>Seam Resource Servlet</servlet-name>
                                  <url-pattern>/seam/resource/*</url-pattern>
                             </servlet-mapping>
                        
                             <!-- Faces 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>Faces Servlet</servlet-name>
                                  <url-pattern>*.xhtml</url-pattern>
                             </servlet-mapping>
                        
                             <!-- JSF parameters -->
                        
                             <context-param>
                                  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                                  <param-value>.xhtml</param-value>
                             </context-param>
                        
                             <context-param>
                                  <param-name>facelets.DEVELOPMENT</param-name>
                                  <param-value>true</param-value>
                             </context-param>
                        
                             <session-config>
                                  <session-timeout>30</session-timeout>
                             </session-config>
                             <welcome-file-list>
                                  <welcome-file>web/home.xhtml</welcome-file>
                             </welcome-file-list>
                        
                             <error-page>
                                  <error-code>500</error-code>
                                  <location>/web/error.html</location>
                             </error-page>
                             <error-page>
                                  <error-code>404</error-code>
                                  <location>/web/pagenotfound.xhtml</location>
                             </error-page>
                        </web-app>
                        
                        




                        but shouldn't this have more to do with Pages not being put in ServletContext????  I can't figure out where Seam puts the instances of the Pages object i ServletContext at all, do you know?


                        • 9. Re: how to debug seam url rewrite
                          Norman Richards Expert

                          I do not see any errors in your configuration.  I applied the same configuration to the blog example and it works fine.  If you have any ideas on how I can reproduce this, I'll take a look at it.

                          • 10. Re: how to debug seam url rewrite
                            Dean Hiller Expert

                            What would really help is if the example in blog directory
                            worked in tomcat....there are a bunch of NoClassDefFound
                            exceptions from jars missing.  Once I get past that,
                            I run into an entitymanager exception and kind of gave up.


                            Why is JSF servlet patter in web.xml /seam/* while
                            the seam filter is /* in the example and rewrite
                            in components.xml is set to /seam/*.


                            which seems odd.  I wish I could get the example working
                            in tomcat so I could just compare one by one.
                            thanks,
                            Dean

                            • 11. Re: how to debug seam url rewrite
                              Dean Hiller Expert

                              I finally made SOME progress. 


                              it looks like it is just a matter of debug=false makes it
                              not work at all!!!!  debug=true fixes the problem.


                              Dean

                              • 12. Re: how to debug seam url rewrite
                                Norman Richards Expert

                                'What would really help is if the example in blog directory
                                worked in tomcat....there are a bunch of NoClassDefFound
                                exceptions from jars missing.  Once I get past that,
                                I run into an entitymanager exception and kind of gave up.'


                                This is with the tomcat-specific deploy targets?  I'm pretty sure we are testing that with every release.  I haven't tried it myself lately, but I'd be quite surprised if it didn't work.





                                'Why is JSF servlet patter in web.xml /seam/* while
                                the seam filter is /* in the example and rewrite
                                in components.xml is set to /seam/*.'


                                That's because the blog example was always done like that, I presume to demonstrate the other normal way of scoping URLs in an app.  The app works fine if you change the pattern.

                                • 13. Re: how to debug seam url rewrite
                                  Norman Richards Expert

                                  'it looks like it is just a matter of debug=false makes it
                                  not work at all!!!!  debug=true fixes the problem.'


                                  Thanks!  I'll investigate monday.  Feel free to open a JIRA if you want to track the progress.