title: "HTTP status 500 - Internal server error" as upload a file over the server
body: <p>I'm trying to upload a file over the local host server but getting and internal server error "Error instantiating the servlet class" while running it.</p>
  
  <p>I have already written a code for uploading the file over the server in the UploadServelet.java class under fileupload package and have also done the mapping of the servelets in web.xml file" but still getting the error.</p>
  
  <hr>
  
  <p><strong>Index.jsp</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="container"&gt;
      &lt;form  method="POST" action="upload" enctype="multipart/form-data"&gt;
  
      &lt;label for="fname"&gt; Select Input File: &lt;/label&gt;                           
      &lt;input type="file" name="myFile" id="myFile"    /&gt; &lt;br/&gt;
      &lt;input type="submit" value="upload" name="upload" id="upload" /&gt;
  
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Web.xml</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"&gt;
      &lt;display-name&gt;Circedb&lt;/display-name&gt;
  
      &lt;servlet&gt;
      &lt;servlet-name&gt;UploadServelet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;src.fileupload.UploadServelet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;UploadServelet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/upload&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
      &lt;session-timeout&gt;
          30
      &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Error logs:
  Type Exception Report
  Message Error instantiating servlet class [<code>src.fileupload.UploadServelet</code>]
  Description The server encountered an unexpected condition that prevented it from fulfilling the request.</p>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>javax.servlet.ServletException: Error instantiating servlet class [src.fileupload.UploadServelet]
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Root Cause</p>
  
  <pre><code>java.lang.ClassNotFoundException: src.fileupload.UploadServelet
      org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1363)
      org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1186)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
      org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
      org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Note The full stack trace of the root cause is available in the server logs.</p>