8 Replies Latest reply on Apr 27, 2009 1:37 PM by arijka.nbardashova.gmail.com

    ajax4jsfFilter - how to tweak it in Seam 2.1?

    rhills

      Profiling of our app has suggested that we have a bottleneck with TIDY parsing of our .seam/.xhtml files.  I've found various links in this forum and elsewhere, but I've found it difficult to work out what is the current best practice for controlling the ajax4jsfFilter.  I've also not been successful in switching OFF parsing for our .seam/.xhtml files.


      I found this resource interesting and apparently useful, though now a little old: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=117190&postdays=0&postorder=asc&start=0.  In this thread, it's suggested that the ajax4jsfFilter can be switched off 'if your XHTML is valid' but that it should be done via settings in components.xml.  In particular, it makes mention of a setting 'forceparser=false'.  I've tried using a web:ajax4jsf-filter element in my components.xml with various permutations of forceparser and regex-url-pattern, but all I manage to do is totally trash the functionality of any pages using A4J forms.


      The following thread on this forum is also useful: http://www.seamframework.org/Community/Ajax4jsffilterForceparserAttributeNotWorking#comment40208.  It's much more recent and in it, Pete Muir says: 'the correct way to set the parser for a4j is in web.xml'.


      I've now removed all web:ajax4jsf-filter elements from my components.xml and put the following into my app's web.xml:


        <context-param>
              <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
              <param-value>NONE,NEKO</param-value>
          </context-param>
      
          <context-param>
              <param-name>org.ajax4jsf.xmlparser.NONE</param-name>
              <param-value>.*\.xhtml|.*\.seam</param-value>
          </context-param>
      



      AFAICT, this should disable all ajax4jsf parsing for .xhtml and .seam files, but any others should fall through to the NEKO parser.  From my logs, the context params seem to be going through OK:


      2008-12-10 11:21:23,052 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter: org.jboss.seam.web.ajax4jsfFilter
      2008-12-10 11:21:23,130 DEBUG [org.ajax4jsf.webapp.BaseFilter] Init ajax4jsf filter with nane: Seam Filter
      2008-12-10 11:21:23,130 DEBUG [org.ajax4jsf.webapp.BaseFilter] Init parameters :
      
      2008-12-10 11:21:23,130 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] init XML filter service with class org.ajax4jsf.webapp.ConfigurableXMLFilter
      2008-12-10 11:21:23,208 INFO  [org.ajax4jsf.cache.CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
      2008-12-10 11:21:23,224 INFO  [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.responseBufferSize=500000, facelets.DEVELOPMENT=false, org.ajax4jsf.COMPRESS_SCRIPT=false, org.richfaces.SKIN=blueSky, com.sun.faces.compressViewState=true, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, com.sun.faces.displayConfiguration=true, org.richfaces.LoadScriptStrategy=ALL, facelets.BUFFER_SIZE=500000, org.richfaces.LoadStyleStrategy=ALL, com.sun.faces.serializeServerState=false, facelets.SKIP_COMMENTS=true, org.ajax4jsf.xmlparser.NONE=.*\.xhtml|.*\.seam, org.ajax4jsf.xmlparser.ORDER=NONE,NEKO, javax.faces.STATE_SAVING_METHOD=client, javax.faces.DEFAULT_SUFFIX=.xhtml}
      2008-12-10 11:21:23,224 INFO  [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
      2008-12-10 11:21:23,302 DEBUG [org.ajax4jsf.resource.InternetResourceService] Resources service initialized
      2008-12-10 11:21:23,317 INFO  [org.ajax4jsf.cache.CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
      2008-12-10 11:21:23,317 INFO  [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {com.sun.faces.responseBufferSize=500000, facelets.DEVELOPMENT=false, org.ajax4jsf.COMPRESS_SCRIPT=false, org.richfaces.SKIN=blueSky, com.sun.faces.compressViewState=true, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, com.sun.faces.displayConfiguration=true, org.richfaces.LoadScriptStrategy=ALL, facelets.BUFFER_SIZE=500000, org.richfaces.LoadStyleStrategy=ALL, com.sun.faces.serializeServerState=false, facelets.SKIP_COMMENTS=true, org.ajax4jsf.xmlparser.NONE=.*\.xhtml|.*\.seam, org.ajax4jsf.xmlparser.ORDER=NONE,NEKO, javax.faces.STATE_SAVING_METHOD=client, javax.faces.DEFAULT_SUFFIX=.xhtml}
      2008-12-10 11:21:23,317 INFO  [org.ajax4jsf.cache.LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
      



      However, when I hit the home page, logging entries suggest to me that it's still being parsed, albeit by the NEKO filter:


      2008-12-10 12:03:42,301 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] create HTML/XML parser for content type: text/html; charset=UTF-8
      2008-12-10 12:03:42,473 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.LT
      2008-12-10 12:03:42,473 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.EXCLAM
      2008-12-10 12:03:42,473 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.DOCTYPESTART
      
      ... lots of FastHtmlParser Parser reached state entries
      
      2008-12-10 12:03:42,598 DEBUG [org.ajax4jsf.io.parser.FastHtmlParser] Parser reached state is StateManager.ELEMENT
      2008-12-10 12:03:42,598 DEBUG [org.ajax4jsf.webapp.BaseXMLFilter] Parsing html total time 187ms
      2008-12-10 12:03:42,598 DEBUG [org.ajax4jsf.webapp.BaseFilter] Finished request processing total time 8312ms for uri: /home.seam
      



      Sorry for the long post, but I've been trying to figure this out for a long time now!

        • 1. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
          rhills

          A followup on this, I've been doing more testing and tried the following configuration in my web.xml:


              <context-param>
                  <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                  <param-value>NONE</param-value>
              </context-param>
          
              <context-param>
                  <param-name>org.ajax4jsf.xmlparser.NONE</param-name>
                  <param-value>.*</param-value>
              </context-param>
          



          AFAICT, that should turn off all parsing of all files.


          However, I'm still seeing all the org.ajax4jsf.io.parser.FastHtmlParser debug entries in my log when I hit the home page, followed by


          13:27:53,497 DEBUG [BaseXMLFilter] Parsing html total time 375ms
          13:27:53,497 DEBUG [BaseFilter] Finished request processing total time 7234ms for uri: /home.seam
          



          So, either I'm completely misunderstanding something, or else something is awfully broken.  I expect that the web.xml config is really a matter for the RichFaces forum.


          Meanwhile, I'd still really appreciate some definitive comment on when one uses web.xml configuration and when one uses components.xml configuration for this filter.


          • 2. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
            rhills

            According to current Seam Documentation: http://docs.jboss.com/seam/2.1.1.CR2/reference/en-US/html/configuration.html#d0e23274, (section 29.1.4.6. RichFaces):



            Seam will install the RichFaces Ajax filter for you, making sure to install it before all other built-in filters. You don't need to install the RichFaces Ajax filter in web.xml  yourself.

            If that's the case, do settings like this in web.xml:


              <context-param>
                    <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                    <param-value>NONE,NEKO</param-value>
                </context-param>
            
                <context-param>
                    <param-name>org.ajax4jsf.xmlparser.NONE</param-name>
                    <param-value>.*\.xhtml|.*\.seam</param-value>
                </context-param>
            


            get fed to the Seam-installed Ajax filter?  In my testing so far, based on limited understanding of it all, they don't seem to be.

            • 3. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
              rhills

              Hmmm, I see that JBoss has adopted GWT (Google Web Toolkit).  Does that mean Ajax4jsf is now dead and that's why I'm getting no bites on this one?

              • 4. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
                gbilodeau

                Have you had any success in solving this?  We're experiencing the same issue - XML parsing eats up around 70% of processing time and adding context parameters to web.xml doesn't seem to have any effect on filter behavior.


                CHeers,
                GB


                • 5. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
                  vladimir.kovalyuk

                  Interesting fact:
                  If you have a very long .xhtml page try to split it into several parts (main page includes some partial .xhtml files). The resulted combination will be handled twice as faster.

                  • 6. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
                    rhills

                    Hi Guillaume,


                    No, unfortunately we've had no replies either here or on the Rich Faces mailing list.  I'm on leave over Christmas but plan to follow this up in the New Year.

                    • 7. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
                      gbilodeau

                      FYI I've succeeded in changing the XML parser by following an example from the Seam distribution, located in examples/hibernate/resources-websphere61 .  Basically you can disable the Ajax4Jsf filter in components.xml then declare it in web.xml - that way the parser parameters are picked up.


                      However after having set the parser to NONE, all Ajax requests never complete.  Setting the parser to NEKO (and putting the neko.jar in the classpath) seems to work and gives a slight performance improvement, but it still gobbles 38% of request processing time.


                      Let me know if you make any progress.


                      Cheers,
                      GB


                      • 8. Re: ajax4jsfFilter - how to tweak it in Seam 2.1?
                        arijka.nbardashova.gmail.com

                        Have you found any solution for this problem?
                        I've got little another problem, that could be solved by disabling ajax4jsf parsers. For some internal reasons it is necessary to send some plain text as response. But, all ajax filters add closing html tag to my responseText.