Roel Meeuws Roel Meeuws - 1 month ago 9
Java Question

Tomcat 8.0.36: WebappClassLoaderBase elusive nullpointerexception

Issue:



The issue is that I am getting a
NullPointerException
in
WebappClassLoaderBase
in Tomcat without too much explanation of why that happens. It starts to happen from version 8.0.35 as far as I can tell.....

The exception trace:



java.lang.NullPointerException
org.apache.catalina.loader.WebappClassLoaderBase.binaryNameToPath(WebappClassLoaderBase.java:2562)
org.apache.catalina.loader.WebappClassLoaderBase.findLoadedClass0(WebappClassLoaderBase.java:2730)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1208)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2508)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2497)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)


The
web.xml
which generates the issue:



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

<servlet>
<servlet-name>FirstServlet</servlet-name>
<async-supported>true</async-supported>
</servlet>

<servlet>
<servlet-name>SecondServlet</servlet-name>
<enabled>false</enabled>
</servlet>

<session-config>
<session-timeout>7</session-timeout>
<cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
</session-config>

<security-constraint>
<display-name>HTTPS</display-name>
<web-resource-collection>
<web-resource-name>HTTPS Constraint</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- IMPORTED web.xml MODULES END -->

</web-app>

Answer

As mentioned in the question. It seems that I solved it by adding <servlet-class> tags in the web.xml file. In my code however I have @WebServlet tags which should already have registered the class names with tomcat. But that's an issue for the bugtracker.