1

What causes this? This appears to be a very comon error with myriad causes.

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)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1149)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1116)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:510)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    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)
note The full stack trace of the root cause is available in the Apache Tomcat/8.5.3 logs.

Here are the includes:

import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;

Adding web.xml Please note: I have tried multiple values for the url-pattern and all it seems to do is change the URI on which I get the error. 'Hello' is the class name in the java source.

<?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>HelloWorldTomcatService</servlet-name>
        <init-param>
            <param-name>com.package.from.java.file</param-name>
            <param-value>Hello</param-value>
        </init-param>
        </servlet>
    <servlet-mapping>
        <servlet-name>HelloWorldTomcatService</servlet-name>
        <url-pattern></url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>
3
  • From the first look it seems to me like an error in servlet or webapp configuration, but it's hard to say without knowing more. Look into catalina.out log file and post the full stack trace, and the web.xml file of your webapp would be also helpful. Commented Jul 22, 2016 at 6:40
  • I think you need to supply: note The full stack trace of the root cause is available in the Apache Tomcat/8.5.3 logs. Commented Jul 22, 2016 at 15:15
  • @RomainHippeau I was unable to find a more detailes stacktrace in any of the log files. Perhaps there's some setting to enable it, but I managed to muddle through without it eventually. Commented Jul 22, 2016 at 21:27

1 Answer 1

2
java.lang.NullPointerException
    java.util.concurrent.ConcurrentHashMap.putVal(Unknown Source)
    java.util.concurrent.ConcurrentHashMap.putIfAbsent(Unknown Source)
    java.lang.ClassLoader.getClassLoadingLock(Unknown Source)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1149)

This specific one can be caused by a web.xml entry which expects a <xxx-class> such as <servlet-class>, <filter-class> or <listener-class>, but it is actually absent or empty.

And indeed, your <servlet> entry is missing the <servlet-class>. It should refer the FQN of the servlet class you'd like to register under the name as specified by <servlet-name> like below.

<servlet>
    <servlet-name>someServlet</servlet-name>
    <servlet-class>com.example.SomeServlet</servlet-class>
</servlet>

That said, your <init-param><param-name> also doesn't look good if it is actually the JAX-RS servlet you tried to register. Are you sure you're reading the right tutorials/resources as to learning JAX-RS and integrating it in Tomcat? A well known one is provided by Lars Vogel.

Sign up to request clarification or add additional context in comments.

1 Comment

I was actually using that tutorial for a while. Eventually I abandoned it and was able to muddle through doing something like what you said.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.