6 Replies Latest reply on Oct 24, 2007 4:08 AM by dmitriy.lapko

    Problem with ajax4jsf resources with WebSphere v6.1.0.9 and

    titou09

      When testing the hibernate2 sample of seam 2.0 beta, on was v6.1.0.9, the ajax4jsf resources URI are not routed to the aja4jsf filter.
      Aja4jsf adds the following line in the pages with aja4jsf tags (ie pages book.xhtml, main.xhml, register.xhtml):

       <script type="text/javascript" src="/<my context root>/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript"></script>
      


      But this resource (it returns the javascript that holds the A4J function) is never processed ("A4J" is not defined in firefox error console) by WAS due to 2 problems :

      First problem:
      It seems that on was v6.1.0.9, a request is routed to a filter only if a servlet-mapping is defined for the URL. In my web.xml file, I have the following for filters and servlets:
       <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>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
       <load-on-startup>2</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.seam</url-pattern>
       </servlet-mapping>
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      


      It seems that even if the URI match the pattern for the filter, the filter never sees this request because (IMO), there is no servlet with a matchng pattern

      Adding the following lines in web.xml makes the "/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript" to be processed by the seam filter
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/a4j.res/*</url-pattern>
       </servlet-mapping>
      

      I will ask the IBM support and eventually open a PMR for this.

      But even with this, the browser never receives the ajax4jsf javascript related to the "/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript" URI.

      Second problem:
      In the org.jboss.seam.servlet.SeamFilter.java at line 66, "bf.getUrlPattern()" for the ajax4jsf filter returns "*.seam"

      So as the requested resource ("/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript" ) does not match the pattern, it is not processed by the ajax4jsf filter.
      In org.jboss.seam.servlet.SeamFilter.java, adding the line "bf.setUrlPattern(null);" in line 66 as follow, makes it work:
       if (filter instanceof AbstractFilter) {
       AbstractFilter bf = (AbstractFilter) filter;
      
       log.debug(" pattern=" + bf.getUrlPattern()); ---> display "*.seam"
       bf.setUrlPattern(null); ---> ugly hack
      
       if (bf.isMappedToCurrentRequestPath(request)) {
       filter.doFilter(request, response, this);
       } else {
       this.doFilter(request, response);
       }
       } else {
       filter.doFilter(request, response, this);
       }
      


      Is this second problem a WebSphere problem? is it a configuration problem? is it a bug in seam?