1 Reply Latest reply on May 9, 2005 2:19 PM by Peter Johnson

    javax.servlet.ServletException: Wrapper cannot find servlet

    Manoj G. Kithany Newbie

      I am using JBoss 4.0.1sp1 on SuSE Linux 9.0 System.

      I have a simplest WEB APPLICATION and access it using http://localhost:8080/mhin/admin.html and here is my Directory structure...


      /jboss/server/default/deploy/mhin.war --> this is a directory.
      /jboss/server/default/deploy/mhin.war/admin.html
      /jboss/server/default/deploy/mhin.war/WEB-INF/web.xml
      /jboss/server/default/deploy/mhin.war/WEB-INF/classes/util/t1.class
      /jboss/server/default/deploy/mhin.war/WEB-INF/classes/util/t2.class
      /jboss/server/default/deploy/mhin.war/WEB-INF/classes/util/p6.class
      /jboss/server/default/deploy/mhin.war/WEB-INF/classes/util/p9.class


      When I click on http://localhost:8080/mhin/admin.html I get following
      ERROR wonder why... (this HTML calls t2.java file)

      -------------------------------------------------------------------
      javax.servlet.ServletException: Wrapper cannot find servlet class util.t2 or a class it depends on

      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:150)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
      org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:300)
      org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:374)
      org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:743)
      org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:675)
      org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:866)
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      java.lang.Thread.run(Thread.java:534)

      root cause

      java.lang.ClassNotFoundException util.t2
      java.net.URLClassLoader$1.run(URLClassLoader.java:199)
      java.security.AccessController.doPrivileged(Native Method)
      -------------------------------------------------------------------

      My WEB.XML file is:
      -------------------------------------------------------------------
      <web-app>

      <servlet-name>t1</servlet-name>
      <servlet-class>util.t1</servlet-class>


      <servlet-name>t2</servlet-name>
      <servlet-class>util.t2</servlet-class>


      <servlet-name>p6</servlet-name>
      <servlet-class>util.p6</servlet-class>


      <servlet-name>p9</servlet-name>
      <servlet-class>util.p9</servlet-class>

      <servlet-mapping>
      <servlet-name>t1</servlet-name>
      <url-pattern>/t1/*</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
      <servlet-name>t2</servlet-name>
      <url-pattern>/t2/*</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
      <servlet-name>p6</servlet-name>
      <url-pattern>/p6/*</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
      <servlet-name>p9</servlet-name>
      <url-pattern>/p9/*</url-pattern>
      </servlet-mapping>
      -------------------------------------------------------------------
      NOTE: t1.java, t2.java, p6.java and p9.java have "package util" in their declarations...

      Questions:
      Are all the classes in the right directory?
      Am I using the right FQDN? Fully Qualified Domain Name? in my WEB.XML?
      Any other hints/ relevant informaiton would be appreciated...


      Sincerely,


      HARI

        • 1. Re: javax.servlet.ServletException: Wrapper cannot find ser
          Peter Johnson Master

          Are all of your classes servlets? I would assume so since they are all listed as servlets in the web.xml file.

          I assume that since the error is on loading util.t2 that admin.html is correctly referencing util.t2. So the question then becomes, on what classes does util.t2 depend and are those classes also available on the classpath?

          Here is a simple example that works (on JBoss 3.2.7, with J2SE 1.4.2):

          class: peter.Hello:

          package peter;
          public class Hello {
           public String toString() {
           return "hello to JBoss";
           }
          }


          index.jsp:
          <html>
          <body>
          <%@ page import="peter.Hello" %>
          <%
           Hello h = new Hello();
          %>
          <h1><%= h.toString() %></h1>
          </body>
          </html>


          web.xml:
          <web-app>
           <welcome-file-list>
           <welcome-file>index.html</welcome-file>
           </welcome-file-list>
          </web-app>



          war file contents:
          ./index.jsp
          ./WEB-INF/web.xml
          ./WEB-INF/classes/peter/Hello.class
          


          Note that I placed my class within the 'peter' package. When it was in the default package, the compiler complained that it did not know how to import Hello (it expected a dot). Seems to be a quirk with JBoss (or Tomcat?).

          I suddenly have other questions. Your primary file is admin.html, not admin.jsp. Are you trying to run an applet? If so, my code above won't help because it is for servlets. What happens if you rename admin.html to admin.jsp? I am curious as to the contents of admin.html.

          Hope this helps.