eclipse-ee4j / eclipse-ee4j/jersey
NullPointerException when declaring Application in web.xml without servlet-class
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
On [https://jersey.java.net/nonav/documentation/2.0/deployment.html](https://jersey.java.net/nonav/documentation/2.0/deployment.html) one of the deployment options described is the following:
{blockquote}
Another deployment option is to declare JAX-RS application details in theweb.xml. This is usually suitable in case of more complex deployments, e.g. when security model needs to be properly defined or when additional initialization parameters have to be passed to Jersey runtime. JAX-RS 1.1 specifies that a fully qualified name of the class that implements Application may be declared in the element of the JAX-RS application's web.xml. This is supported in a Web container implementing Servlet 3.0 as follows:
Example 4.5\. Deployment of a JAX-RS application using web.xml with Servlet 3.0
org.foo.rest.MyApplication
...
org.foo.rest.MyApplication
/resources
...
Note that the element is omitted from the servlet declaration. This is a correct declaration utilizing the Servlet 3.0 extension mechanism. Also note that is used to define the base resource URI.{blockquote}
However, when I try this on Payara Micro 4.1.1.164, I get a NullPointerException:
```
java.lang.NullPointerException
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.addServletWithExistingRegistration(JerseyServletContainerInitializer.java:316)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartupImpl(JerseyServletContainerInitializer.java:161)
at org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.onStartup(JerseyServletContainerInitializer.java:144)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:6062)
... 34 more
```
It seems that Payara/Glassfish interprets a missing servlet class as the entry in web.xml as indicating that the servlet is a JSP and then the dynamic registration in JerseyServletContainerInitializer fails because a servlet of the same name already exists.
I can't quite tell whether this is a Glassfish or Jersey issue, so please advise.
At the very least, I think the documentation at [https://jersey.java.net/nonav/documentation/2.0/deployment.html](https://jersey.java.net/nonav/documentation/2.0/deployment.html) should warn that the "servlet 3.0 extension mechanism" doesn't work on Glassfish/Payara 4.1.1.
#### Environment
Payara Micro 4.1.1.164
Contributor guide
Research direction
Reproduce the web.xml deployment on Payara Micro 4.1.1.164, then inspect org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer.java around line 316 and the deployment documentation linked in the issue. Determine whether the failure belongs to Jersey or GlassFish/Payara, and finish with a compatible fix or an accurate documentation warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100