2 Replies Latest reply on Nov 9, 2006 9:10 AM by malmit

    JBoss 4.0.5 servlet filter problem in web.xml

    rayymlai

      I write a simple JSF hello world page index.jsp and deploy to JBoss 4.0.5. it seems that JBoss can only accept .faces extension, despite I define the Faces servlet filter with *.jsp.

      Setup
      1. My simple JSF apps has only one page index.jsp,
      which is a simple hello world app, e.g.






      Hello world, hi there.




      2. I have a simple web.xml that defines the servlet filter with *.jsp (instead of .faces).
      e.g.
      <?xml version="1.0" encoding="UTF-8"?>

      <web-app version="2.4"
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


      <display-name>xxx</display-name>

      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>

      <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsp</url-pattern>
      </servlet-mapping>

      <!-- Welcome File List -->
      <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>

      </web-app>

      3. A simple, vanilla faces-config.xml
      e.g.
      <?xml version="1.0" encoding="UTF-8"?>

      <faces-config>

      <locale-config>
      <default-locale>en</default-locale>
      </locale-config>

      </faces-config>


      Problems
      1. upon successful deployment to JBoss, if I type
      http://localhost:8080/xxx/index.jsp

      JBoss will generate "non-stoppable" exceptions in the server console for a few minutes, and ends up with an exception on the Web browser:

      exception

      javax.servlet.ServletException: javax.servlet.ServletException
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      root cause

      javax.faces.FacesException: javax.servlet.ServletException
      org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:422)
      org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
      org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)



      2. if I type
      http://localhost:8080/xxx/index.faces

      the system will work and show hello world message.

      Note: if I put *.faces in the faces servlet filter in the web.xml, the system will work as well.

      3. JBoss does not seem to accept the faces servlet with a non-*.faces entry. I understand that *.faces is a recommended practice from the JSF spec, but in reality, many people use *.jsf or even *.jsp in the servlet filter.

      Implication - I can only use *.faces in the URL for JSF apps.

      Could anyone tell me whether I miss anything, or whether this is a specific JBoss implementation?

      Thanks


        • 1. Re: JBoss 4.0.5 servlet filter problem in web.xml
          rayymlai

          This setup will work:


          1. web.xml :

          <!-- Faces Servlet Mapping -->
          <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.faces</url-pattern>
          </servlet-mapping>

          <!-- Welcome File List -->
          <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>

          2. In the browser, enter

          http://localhost:8080/xxx/
          or http://localhost:8080/xxx/index.faces
          or http://localhost:8080/xxx/index.jsp

          However, if you specify
          *.jsp in the url-pattern of the web.xml,
          JBoss will spin a few minutes when generating exceptions

          I deploy the same JSF app in BEA Weblogic or Sun Java, and I don't have the same problem.

          Questions

          Any pointer to why?
          Is this a bug in JBoss's implementation of the servlet filter?
          Thanks

          • 2. Re: JBoss 4.0.5 servlet filter problem in web.xml
            malmit

            I've got a different problem. I am trying to build a document literal web service in JBoss 4.0.5 and can't get around this exception:

            org.jboss.ws.WSException: Cannot obtain java/xml type mapping for: {http://www.w3.org/2001/XMLSchema}base64Binary

            Here's what my wsdl looks like:

            <SOAP:binding style="document" transport="http://schemas.xmlsoap.org/soap/http">


            <SOAP:operation style="document" soapAction="Ping">
            < input>
            <mime:multipartRelated>
            <mime:part>
            <SOAP:body use="literal"/>
            </mime:part>
            <mime:part>
            <mime:content part="data" type="gzip"/>
            </mime:part>
            </mime:multipartRelated>
            </ input>
            < output>
            <SOAP:body use="literal"/>
            </ output>
            </SOAP:operation>

            </SOAP:binding>


            In my mapping.xml file that wscompile generated, this mapping was generated for the data mime:content:

            <variable-mapping>
            <java-variable-name>data</java-variable-name>
            <xml-element-name>data</xml-element-name>
            </variable-mapping>

            My ultimate goal is to allow a web service request containing parameters passed via a normal web service request and allow an attachment of a base64 encoded binary file. Is this a bug in JBoss 4.0.5?