title: Error: Wrapper cannot find servlet class com.HelloCedarville or a class it depends on
body: <p>So I am trying to get a simple Hello World application working using a Java servlet. This is for a Web Apps class I'm taking. My issue is that I keep getting an error saying that my "HelloCedarville.class" file cannot be found. </p>
  
  <p>I have tried many things to get this to work:</p>
  
  <ol>
  <li>At first I tried this without a java package, in other words the .class file was directly under /WEB-INF/classes, but this didn't work.</li>
  <li>Next I tried it using a java package (as many of the answers to similar questions suggested to use a java package). I made sure the compiled java class "HelloCedarville.class" is under /WEB-INF/classes/com, and that "package com;" is at the top of "HelloCedarville.java". </li>
  <li>I have checked my "web.xml" file multiple times to make sure that I mapped to the servlet correctly. </li>
  <li>I tried recompiling the java file and retesting to see if it can find the .class file.</li>
  <li>I tried deleting both "HelloCedarville.java" and "HelloCedarville.class" and recreating them.</li>
  </ol>
  
  <p>I just can't figure out what is causing this error. Here is the full error:</p>
  
  <pre><code>HTTP Status 500 - 
  
  type Exception report
  
  message
  
  description The server encountered an internal error () that prevented it from fulfilling this request.
  
  exception
  
  javax.servlet.ServletException: Wrapper cannot find servlet class com.HelloCedarville or a class it depends on
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
      org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
      org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
      org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
      org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
      java.lang.Thread.run(Thread.java:724)
  root cause
  
  java.lang.ClassNotFoundException: com.HelloCedarville
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
      org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
      org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
      org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
      org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
      org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
      org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
      java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <p>Here is the web.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
  
  &lt;web-app&gt;
    &lt;context-param&gt;
       &lt;param-name&gt;driver&lt;/param-name&gt;
       &lt;param-value&gt;com.mysql.jdbc.Driver&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
       &lt;param-name&gt;connection&lt;/param-name&gt;
       &lt;param-value&gt;jdbc:mysql://john.cedarville.edu/cs4220&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
       &lt;param-name&gt;username&lt;/param-name&gt;
       &lt;param-value&gt;cs4220&lt;/param-value&gt;
    &lt;/context-param&gt;
    &lt;context-param&gt;
       &lt;param-name&gt;password&lt;/param-name&gt;
       &lt;param-value&gt;&lt;/param-value&gt;
    &lt;/context-param&gt;
     &lt;servlet&gt;
      &lt;!-- Arbitrary servlet name --&gt;
      &lt;servlet-name&gt;servlet2&lt;/servlet-name&gt;
      &lt;!-- The name of the class you want to run --&gt;
     &lt;servlet-class&gt;com.HelloCedarville&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;!-- Must match the same as above --&gt;
      &lt;servlet-name&gt;servlet2&lt;/servlet-name&gt;
      &lt;!-- maps the servlet to a specific URL in this case it
      would be judah/&lt;your login name&gt;/servlet/RequestInfoExample --&gt;
      &lt;url-pattern&gt;/HelloCedarville&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;servlet&gt;
      &lt;!-- Arbitrary servlet name --&gt;
      &lt;servlet-name&gt;servlet&lt;/servlet-name&gt;
      &lt;!-- The name of the class you want to run --&gt;
      &lt;servlet-class&gt;HelloWorld&lt;/servlet-class&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;!-- Must match the same as above --&gt;
      &lt;servlet-name&gt;servlet&lt;/servlet-name&gt;
      &lt;!-- maps the servlet to a specific URL in this case it
      would be judah/&lt;your login name&gt;/servlet/RequestInfoExample --&gt;
      &lt;url-pattern&gt;/HelloWorld&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Here is the java code of HelloCedarville.java:</p>
  
  <pre><code>package com;
  
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  public class HelloCedarville extends HttpServlet {
  
      public void init(ServletConfig config) throws ServletException {
          super.init(config);
      }   
  
      public void doGet(HttpServletRequest request, HttpServletResponse response)
                      throws ServletException, IOException {
  
      doPost(request,response);
      }
  
      public void doPost(HttpServletRequest request, 
                                      HttpServletResponse response)
                      throws ServletException, IOException {
  
          response.setContentType("text/html");
          PrintWriter out = response.getWriter();
  
          String docType = "&lt;!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
                                        "Transitional //EN\"&gt;\n";
          out.println (docType + "&lt;html&gt;\n" + "&lt;head&gt;&lt;title&gt;" + 
                             "Hello Cedarville&lt;/title&gt;&lt;/head&gt;\n" + "&lt;body&gt;\n" +
                             "&lt;h1&gt;Hello Cedarville&lt;/h1&gt;\n" + "&lt;/body&gt;&lt;/html&gt;\n");
      }
  }
  </code></pre>