1 Reply Latest reply on Aug 5, 2011 3:00 PM by shelleyb

    JSP Servlet Mapping

    shelleyb

      When mapping a servlet to a jsp-file rather than a servlet-class on JBoss AS 7, the servlet is marked as unavailable due to the following exception: "javax.servlet.ServletException: No servlet class has been specified for servlet jsp."

      12:29:36,992 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/jsp-test]] (MSC service thread 1-10) Servlet /jsp-test threw load() exception: javax.servlet.ServletException: No servlet class has been specified for servlet jsp
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1149) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
          at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
          at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3844) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
          at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
      

      The servlet mapping is as follows in my 2.5 web deployment descriptor:

          <servlet>
              <servlet-name>jsp</servlet-name>
              <jsp-file>/jsp.jspx</jsp-file>
          </servlet>
          <servlet-mapping>
              <servlet-name>jsp</servlet-name>
              <url-pattern>/jsp</url-pattern>
          </servlet-mapping>
      

      The servlet specification allows servlets to be mapped to either a servlet-class or jsp-file, so the web.xml itself is valid. I'm wondering why the exception seems to indicate that a servlet class must be specified.  Also note that this code deploys and runs correctly on Tomcat 7 and WAS 7. Is there something else that I need to configure to allow this servlet to load?

        • 1. Re: JSP Servlet Mapping
          shelleyb

          It appears that this problem was caused by the use of the "jsp" servlet-name which I was using for testing purposes. Most likely, the "jsp" servlet-name was already reserved by the container. After I changed it to something other than "jsp," everything worked as expected.

              <servlet>
                  <servlet-name>jspTest</servlet-name>
                  <jsp-file>/jsp.jspx</jsp-file>
              </servlet>
              <servlet-mapping>
                  <servlet-name>jspTest</servlet-name>
                  <url-pattern>/jsp</url-pattern>
              </servlet-mapping>
          

          It was a little bit surprising that this worked on Tomcat though, since my understanding was that JBoss was built on Catalina. After testing it on geronimo-tomcat7-javaee6-3.0-M1, it failed with the same error, though, so there must be something different with Tomcat. Fortunately, deploying to geronimo-jetty7-javaee5-2.2.1 gave me a much more useful exception message "org.apache.geronimo.common.DeploymentException: jsp servlet already present" that lead me to test the use of a different servlet-name.