title: Calling servlet from tomcat throws HTTP Status 500 java.lang.NullPointerException
body: <p>I am new to J2EE and build a sample project using tomcat and eclipse. While the index.html load properly but when i submit the page (or make call to servlet), i received below exception</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 
  java.lang.NullPointerException
  java.util.concurrent.ConcurrentHashMap.putVal(Unknown Source)
  java.util.concurrent.ConcurrentHashMap.putIfAbsent(Unknown Source)
  java.lang.ClassLoader.getClassLoadingLock(Unknown Source)
  java.lang.ClassLoader.loadClass(Unknown Source)
  java.lang.ClassLoader.loadClass(Unknown Source)
  org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1641)
  org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
  org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
  org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
  org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
  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>Following are the files i have created</p>
  
  <p>1) index.html </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method="post" action="SelectCoffee.do"&gt;
  select coffee
  &lt;select name="taste" size="1"&gt;
  &lt;option value="dark"&gt;dark&lt;/option&gt;
  &lt;option value="latte"&gt;latte&lt;/option&gt;
  &lt;option value="cold"&gt;cold&lt;/option&gt;
  &lt;option value="chocolate"&gt;chocolate&lt;/option&gt;
  &lt;/select&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>2)web.xml</p>
  
  <pre><code>&lt;web-app 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/web-app_2_4.xsd"  version="2.4"&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;For Coffee&lt;/servlet-name&gt;
  &lt;sevlet-class&gt;com.example.web.CoffeeSelect&lt;/sevlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;For Coffee&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/SelectCoffee.do&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>3) CoffeeSelect.java</p>
  
  <pre><code>package com.example.web;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import java.io.*;
  public class CoffeeSelect extends HttpServlet{
  public void doPost(HttpServletRequest request, HttpServletResponse response) 
          throws IOException,ServletException{
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("Cofee Advice");
      String c= "mine : " + request.getParameter("taste");
      out.println("&lt;br&gt;Got taste = "+c);
  }}
  </code></pre>
  
  <p>Also let me know if anything else is required. Please help as this may get me a job :(</p>