eclipse-ee4j / eclipse-ee4j/jersey
javax.servlet.ServletException: Resource configuration class [Application] is not a subclass of class javax.ws.rs.core.Application
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
I have a web application where the javax.ws.rs.core.Application is provided by tomcat rather than embedded in the war file.
This triggers failure as follows:
```
javax.servlet.ServletException: Resource configuration class [Application] is not a subclass of class javax.ws.rs.core.Application.
at org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:517)
at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:275)
```
This happens because a check is being made with class.isAssignableFrom(), which fails if the classes are in different classloaders.
https://github.com/eclipse-ee4j/jersey/blob/2.x/containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/WebComponent.java#L513
The fix seems to be changing this check to not use class.isAssignableFrom().
Contributor guide
Research direction
Start by reading containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/WebComponent.java around line 513, then inspect how the resource configuration class is checked. Reproduce the deployment with javax.ws.rs.core.Application supplied by Tomcat rather than the WAR, and verify that startup no longer raises the reported ServletException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100