pax-web is not discovering jakarta annotations #2105
-
|
I'm currently in process of migrating application to pax 11 with jetty 12. We are using new jakarta 6.1. But unfortunately it looks as the osgi bundles containg Web-ContextPath are not scanned for those annotations and servlets/filters are not registered. If everything is defined in web.xml then it works as expected. I assume I'm missing something in my osgi server. Those are the pax-web libraries together with jetty ones: org.eclipse.jetty-xml-12.0.22.jar Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 1 reply
-
|
Hmm, we have annotated servlet example here: https://github.com/ops4j/org.ops4j.pax.web/blob/pax-web-11.0.x/samples/samples-war/war-security/src/main/java/org/ops4j/pax/web/samples/war/security/FullyAnnotatedServlet.java And the integration tests using this WAR/WAB sample is here: https://github.com/ops4j/org.ops4j.pax.web/blob/pax-web-11.0.x/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/war/AbstractWarSecurityIntegrationTest.java So in theory it should work There should be something in the logs you could check... |
Beta Was this translation helpful? Give feedback.
-
|
Usually, in OSGi runtimes such error may be caused by multiple bundles exporting |
Beta Was this translation helpful? Give feedback.
-
|
I just discovered if I wrap my classes into WEB-INF/classes and add Bundle-ClassPath: WEB-INF/classes then everything is working wcorrectly. But if my classes resides in root dir with Bundle-ClassPath: . then nothing is discovered. Is it required to include classes in WEB-INF directory? |
Beta Was this translation helpful? Give feedback.
-
|
In theory it should. There's special code for checking There's a sample using So there may be an issue with You can increase logging level for I'll check later if this works, but rather later next week. Mind that the root of the WAB is supposed to contain web resources, so you will be able to retrieve them using HTTP! You should rather not allow users to get your |
Beta Was this translation helpful? Give feedback.
-
|
I believe there is an issue in the code. Created a ticket: And a pull request: If it could be merged and a new artifact produced that would be great as this is blocking us from moving forward with migration. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks! I'll review at earliest on Monday, but you can expect a release the same week. |
Beta Was this translation helpful? Give feedback.
-
|
Check out this: https://docs.osgi.org/specification/osgi.cmpn/8.0.0/service.war.html#i3096883
So in practice this obvious issue was by accident a protection, because root content of the bundle could not be exposed as web resources even if There's nothing in the spec that say it should be prevented, so I suggest fixing this (with your PR), but with a WARNING that it makes the classes available to external users. |
Beta Was this translation helpful? Give feedback.
-
|
Also you you have cl.getResource('com/example/MyClass.class');
cl.getResource('WEB-INF/classes/com/example/MyClass.class');which may be a bit confusing. |
Beta Was this translation helpful? Give feedback.
-
|
If you are using both then yes it will be loaded twice. But the '.' should never be used together with 'WEB-INF/classes'. And we are not using it. It might be a security issue I agree but nothing prevents end user from using it like this. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry for no responses - I was super busy with my daily job. |
Beta Was this translation helpful? Give feedback.
-
|
#2106 is now fixed. |
Beta Was this translation helpful? Give feedback.
#2106 is now fixed.