Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undetermined behaviour with @ApplicationPath #5403

Open
gluser1357 opened this issue Aug 31, 2023 · 4 comments
Open

Undetermined behaviour with @ApplicationPath #5403

gluser1357 opened this issue Aug 31, 2023 · 4 comments

Comments

@gluser1357
Copy link

Hi, after deploying a Jersey 3.1.3 webapp using @ApplicationPath, without referencing the application class in web.xml, the registered resources for this application might sometimes be undetermined (using Tomcat 10.1 container).

For me it seems to be a timing issue during startup of an webapp, possibly related with the mechamism of automatic adding of Servlets as mentioned in https://eclipse-ee4j.github.io/jersey.github.io/documentation/3.1.3/deployment.html: "If no such Servlet is defined to handle the custom Application subclass, Jersey dynamically adds a Servlet with a fully qualified name equal to the name of the provided Application subclass.".

Possible workaround: Replace @ApplicationPath in the application class with an approriate entry in web.xml (as described in the docs).

See more details here: https://stackoverflow.com/questions/76779528/undetermined-registration-of-resources-while-migrating-to-jersey-3-1-x

@jansupol
Copy link
Contributor

There is a difference between Jersey 2.x and 3.1 regarding the @ApplicationPath. While 2.x does handle @ApplicationPath in its servlet module, and the deployment path is not used when deploying to outside of the ServletContainer, Jersey 3.1 handles @ApplicationPath in the server part so that the path is reflected in deployments of outside Servlet environments.

However, you also describe (in SO) the problems with scanning classes. The classes are scanned by the Servlet autodiscovery mechanism in both cases, Jersey 2.x and 3.x (when not used web.xml) and that's outside of Jersey.

Anyway, could you please create a sample project that demonstrates the issue?

@gluser1357
Copy link
Author

Hi and thank you again for your fast response! I'll try when time allows it. I'm also thinking about add some code to demonstrate issues #5402 and #4867 into the demo. Where and how can I put the code when ready, as simple maven project attached as file in this thread?

@jansupol
Copy link
Contributor

Would it be possible to create a new GitHub repository with the demo and reference it here?

@gluser1357
Copy link
Author

Short update: I'm now trying for some hours to reproduce this issue with a Tomcat setup that should actually be very close to the one I used when I found this issue. But currently I can't reproduce it. Meanwhile we changed some webapps in the Tomcat container and made some configuration changes for Tomcat in files we don't have approriate backups for. I have no idea what else the missing point could be, so I currently cannot provide more details than I had written here and in SO.

If we are ever able do reproduce the issue again I'll freeze everything to set up a reproducable test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants