Re: Tomcat 8.5.12 - NPE when using RequestDispatcher

2017-03-23 Thread Thomas DELHOMENIE
2017-03-23 21:50 GMT+01:00 Violeta Georgieva :

> Hi,
>
> 2017-03-23 22:47 GMT+02:00 Thomas DELHOMENIE  >:
> >
> > Hi,
> >
> > With Tomcat 8.5.12 I hit a NPE when I use RequestDispatcher to redirect
> > from a servlet to another one in the case of the mapping of this second
> > servlet ends with /*. An error 500 is returned because of a
> > NullPointerException :
>
> Most probably you are facing this issue [1].
> The fix will be available in 8.5.13.
>
> Regards,
> Violeta
>
> [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60882


Yes, very probably :)
Thanks!


>
>
> >  java.lang.NullPointerException
> > at
> >
> org.apache.catalina.core.ApplicationMapping.getServletMapping(
> ApplicationMapping.java:62)
> > at
> >
> org.apache.catalina.core.ApplicationContext.getRequestDispatcher(
> ApplicationContext.java:486)
> > at
> >
> org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(
> ApplicationContextFacade.java:222)
> > at org.exoplatform.RedirectServlet.doGet(
> RedirectServlet.java:19)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:230)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
> > at
> > org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:192)
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:165)
> > at
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:198)
> > at
> >
> org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:96)
> > at
> >
> org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:140)
> > at
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java:80)
> > at
> >
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(
> AbstractAccessLogValve.java:624)
> > at
> >
> org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:87)
> > at
> >
> org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java:341)
> > at
> > org.apache.coyote.http11.Http11Processor.service(
> Http11Processor.java:783)
> > at
> >
> org.apache.coyote.AbstractProcessorLight.process(
> AbstractProcessorLight.java:66)
> > at
> >
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(
> AbstractProtocol.java:798)
> > at
> >
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.
> doRun(NioEndpoint.java:1441)
> > at
> >
> org.apache.tomcat.util.net.SocketProcessorBase.run(
> SocketProcessorBase.java:49)
> > at
> >
> java.base/java.util.concurrent.ThreadPoolExecutor.
> runWorker(ThreadPoolExecutor.java:1161)
> > at
> >
> java.base/java.util.concurrent.ThreadPoolExecutor$
> Worker.run(ThreadPoolExecutor.java:635)
> > at
> >
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(
> TaskThread.java:61)
> > at java.base/java.lang.Thread.run(Thread.java:844)
> >
> > To reproduce this issue I created a simple war with the following web.xml
> :
> >
> > http://xmlns.jcp.org/xml/ns/javaee;
> >   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
> >   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> >   http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd
> "
> >   version="3.1"
> >   metadata-complete="true">
> >
> > 
> >   Servlet and JSP Examples.
> > 
> > Servlet and JSP Examples
> >
> > 
> >   HelloWorldExample
> >   org.sample.HelloWorldServlet
> > 
> > 
> > RedirectServlet
> > org.sample.RedirectServlet
> > 
> >
> > 
> > HelloWorldExample
> > /HelloWorldExample/*
> > 
> > 
> > RedirectServlet
> > /RedirectServlet
> > 
> > 
> >
> > The class RedirectServlet is :
> >
> > package org.sample;
> >
> > import javax.servlet.RequestDispatcher;
> > import javax.servlet.ServletException;
> > import javax.servlet.http.HttpServlet;
> > import javax.servlet.http.HttpServletRequest;
> > import javax.servlet.http.HttpServletResponse;
> > import java.io.IOException;
> >
> > public class RedirectServlet extends HttpServlet {
> >   @Override
> >   public void doGet(HttpServletRequest request,
> > HttpServletResponse response)
> >   throws IOException, ServletException
> >   {
> > RequestDispatcher requestDispatcher =
> > request.getServletContext().getRequestDispatcher("/HelloWorldExample");
> >

Re: Tomcat 8.5.12 - NPE when using RequestDispatcher

2017-03-23 Thread Violeta Georgieva
Hi,

2017-03-23 22:47 GMT+02:00 Thomas DELHOMENIE :
>
> Hi,
>
> With Tomcat 8.5.12 I hit a NPE when I use RequestDispatcher to redirect
> from a servlet to another one in the case of the mapping of this second
> servlet ends with /*. An error 500 is returned because of a
> NullPointerException :

Most probably you are facing this issue [1].
The fix will be available in 8.5.13.

Regards,
Violeta

[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=60882

>  java.lang.NullPointerException
> at
>
org.apache.catalina.core.ApplicationMapping.getServletMapping(ApplicationMapping.java:62)
> at
>
org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:486)
> at
>
org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:222)
> at org.exoplatform.RedirectServlet.doGet(RedirectServlet.java:19)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
> at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
> at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
> at
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> at
>
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
> at
>
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
> at
>
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
> at
>
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> at
>
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
> at
>
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
> at
>
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
> at
>
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
> at
>
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
> at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
> at
>
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> at
>
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
> at
>
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441)
> at
>
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> at
>
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1161)
> at
>
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
> at
>
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.base/java.lang.Thread.run(Thread.java:844)
>
> To reproduce this issue I created a simple war with the following web.xml
:
>
> http://xmlns.jcp.org/xml/ns/javaee;
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
>   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>   http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd;
>   version="3.1"
>   metadata-complete="true">
>
> 
>   Servlet and JSP Examples.
> 
> Servlet and JSP Examples
>
> 
>   HelloWorldExample
>   org.sample.HelloWorldServlet
> 
> 
> RedirectServlet
> org.sample.RedirectServlet
> 
>
> 
> HelloWorldExample
> /HelloWorldExample/*
> 
> 
> RedirectServlet
> /RedirectServlet
> 
> 
>
> The class RedirectServlet is :
>
> package org.sample;
>
> import javax.servlet.RequestDispatcher;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import java.io.IOException;
>
> public class RedirectServlet extends HttpServlet {
>   @Override
>   public void doGet(HttpServletRequest request,
> HttpServletResponse response)
>   throws IOException, ServletException
>   {
> RequestDispatcher requestDispatcher =
> request.getServletContext().getRequestDispatcher("/HelloWorldExample");
> requestDispatcher.forward(request, response);
>   }
> }
>
> And the class HelloWorldServlet is :
>
> package org.sample;
>
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import java.io.IOException;
> import java.io.PrintWriter;
>
> public class HelloWorldServlet extends HttpServlet {
>   @Override
>   public void 

Tomcat 8.5.12 - NPE when using RequestDispatcher

2017-03-23 Thread Thomas DELHOMENIE
Hi,

With Tomcat 8.5.12 I hit a NPE when I use RequestDispatcher to redirect
from a servlet to another one in the case of the mapping of this second
servlet ends with /*. An error 500 is returned because of a
NullPointerException :

 java.lang.NullPointerException
at
org.apache.catalina.core.ApplicationMapping.getServletMapping(ApplicationMapping.java:62)
at
org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:486)
at
org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:222)
at org.exoplatform.RedirectServlet.doGet(RedirectServlet.java:19)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441)
at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1161)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)

To reproduce this issue I created a simple war with the following web.xml :

http://xmlns.jcp.org/xml/ns/javaee;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
  http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd;
  version="3.1"
  metadata-complete="true">


  Servlet and JSP Examples.

Servlet and JSP Examples


  HelloWorldExample
  org.sample.HelloWorldServlet


RedirectServlet
org.sample.RedirectServlet



HelloWorldExample
/HelloWorldExample/*


RedirectServlet
/RedirectServlet



The class RedirectServlet is :

package org.sample;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RedirectServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest request,
HttpServletResponse response)
  throws IOException, ServletException
  {
RequestDispatcher requestDispatcher =
request.getServletContext().getRequestDispatcher("/HelloWorldExample");
requestDispatcher.forward(request, response);
  }
}

And the class HelloWorldServlet is :

package org.sample;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class HelloWorldServlet extends HttpServlet {
  @Override
  public void doGet(HttpServletRequest request,
HttpServletResponse response)
  throws IOException, ServletException
  {
PrintWriter out = response.getWriter();

out.println("");
out.println("");
out.println("");
out.println("Hello World");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("");
out.println("Hello World !");
out.println("");
out.println("");
  }
}

I do not have 

Re: Tomcat Not Responding

2017-03-23 Thread Mark Thomas
On 23/03/17 05:07, Igal @ Lucee.org wrote:
> Hi Mark,
> 
> On 3/22/2017 1:00 PM, Mark Thomas wrote:
>> On 22/03/17 16:20, Igal @ Lucee.org wrote:
>>> Looks like all the threads are waiting on the same lock?
>> Agreed. But I don't see anything holding that lock. That looks like a
>> JVM bug to me.
> 
> Thank you for replying.  I managed to "do" it again.  This time on
> Tomcat 8.5.11 so I modified the subject line slightly.  But this time I
> took both a thread dump (attached) and a heap dump.
> 
> I should mention that my code utilizes JSR-356 WebSockets, I'm not sure
> if that's related, but it seems to be a factor in reproducing the issue.
> 
> I will try to create a reduced test case.
> 
> I am hoping that the screenshots below, showing references to and from
> the lock object at 0x0006c0dbc1b8, can give you some more
> information that may help to diagnose this issue, or at least give some
> ideas about what to look for next:

I took another look and those threads are in the normal state you'd
expect for threads in the pool waiting for work.

If Tomcat is unresponsive, that would suggest a problem with either the
Acceptor or the Poller but both of those threads look normal to.

You are going to need to do some more debugging.

Ideally, you need to configure your favourite IDE to do remote debugging
and then once the problem occurs, step through the code as a single
connection is handled and see where things go wrong.

Based on what I see in the thread dumps (all normal) I'd also check that
your test is doing what it is meant to.

Mark


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org