title: NullPointerException in Request.notifyAttributeAssigned
body: <p>I am not sure what's wrong with this code snippet:</p>
  
  <pre><code>public class RequestProcessor extends Thread{
      private ServletContext context;
      private HttpServletRequest request;
      private HttpServletResponse response;
  
      public RequestProcessor(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) {
          this.context = servletContext;
          this.request = request;
          this.response = response;
          handler = HandlerFactory.getFactory(request);
  
          start();            
      }
  
      public void run(){
          RequestDispatcher dispatcher = context.getRequestDispatcher("/index.jsp");
  
          try {
              dispatcher.forward(request, response);
          } catch (ServletException e) {
          } catch (IOException e) {
          }
      }   
  </code></pre>
  
  <p>These threads are enqueued [method <code>enqueue()</code>] in a <code>ArrayBlockingQueue</code> and parameters are taken from a normal <code>HttpServlet</code>.</p>
  
  <p>So, the doGet() from the HttpServlet:</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      scheduler.enqueue(getServletContext(), request, response);
  }
  </code></pre>
  
  <p>I have a Java exception, there's a problem with with the forwarding.</p>
  
  <p>What's wrong with my code?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Take a look to this stack trace:</p>
  
  <pre><code>Servlet.service() for servlet RequestDispatcher threw exception
  java.lang.NullPointerException
      at org.apache.catalina.connector.Request.notifyAttributeAssigned(Request.java:1563)
      at org.apache.catalina.connector.Request.access$000(Request.java:107)
      at org.apache.catalina.connector.Request$3.set(Request.java:3369)
      at org.apache.catalina.connector.Request.setAttribute(Request.java:1515)
      at org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:542)
      at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:286)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
      at source.RequestProcessor.run(RequestProcessor.java:42)
  Exception in thread "Thread-3" java.lang.NullPointerException
      at org.apache.catalina.connector.Request.notifyAttributeAssigned(Request.java:1563)
      at org.apache.catalina.connector.Request.access$000(Request.java:107)
      at org.apache.catalina.connector.Request$3.set(Request.java:3369)
      at org.apache.catalina.connector.Request.setAttribute(Request.java:1515)
      at org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:542)
      at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:286)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
      at source.RequestProcessor.run(RequestProcessor.java:42)
  </code></pre>