Hello,
i tried to work with glassfish-jersey.
If i use the all-in-one bundle (eclipsesource or selfe-bundled) everything is fine.
But why using all-in-one bundles when all jar's are bundles.
In the project are all dependencys by using aQute.bnd.repository.maven.provider.MavenBndRepository
I run the Projekt with this requieres bundles:
https://github.com/JohneDoe/osgi-sandbox-runrequires: \
osgi.identity;filter:='(osgi.identity=org.apache.felix.webconsole)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.jline)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
osgi.identity;filter:='(osgi.identity=org.glassfish.hk2.osgi-resource-locator)',\
osgi.identity;filter:='(osgi.identity=org.glassfish.jersey.inject.jersey-hk2)',\
osgi.identity;filter:='(osgi.identity=my.sandbox.rs.server)',\
osgi.identity;filter:='(osgi.identity=my.sandbox.rs.server.example)'
org.glassfish.jersey.inject.jersey-hk2 -> HK2 injection for jersey
org.glassfish.hk2.osgi-resource-locator ->rely on META-INF/services mechanism to locate providers
Depending on the order of the bundles in the -runbundles: property it runs or fails
runing (servlet bundles at last position?):
https://github.com/JohneDoe/osgi-sandbox/blob/master/my.sandbox.rs/Example1Working.bndrunhttps://github.com/JohneDoe/osgi-sandbox/blob/master/my.sandbox.rs/Example2Working.bndrunfailing:
https://github.com/JohneDoe/osgi-sandbox/blob/master/my.sandbox.rs/Example1Fail.bndrunhttps://github.com/JohneDoe/osgi-sandbox/blob/master/my.sandbox.rs/Example2Fail.bndrunwhen failing the problem is that the:
org.glassfish.hk2.osgi-resource-locator did not Activate.
lb:
23|Active | 1|javax.inject:1 as OSGi bundle (2.5.0.b36)|2.5.0.b36
24|Active | 1|ServiceLocator Default Implementation (2.5.0.b36)|2.5.0.b36
25|Starting | 1|OSGi resource locator bundle - used by various API providers that rely on META-INF/services mechanism to locate providers. (1.0.1)|1.0.1
26|Active | 1|HK2 Implementation Utilities (2.5.0.b36)|2.5.0.b36
27|Active | 1|jersey-container-servlet-core (2.26.0.b06)|2.26.0.b06
28|Active | 1|jersey-core-client (2.26.0.b06)|2.26.0.b06
and because of that it could not read the META-INF/services and lookup the InjectionManagerFactory
[ERROR] ([javax.servlet.Servlet]) Error during calling init() on servlet my.sandbox.rs.server.example.ExampleServlet@3116c353
java.lang.IllegalStateException: InjectionManagerFactory not found.
at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:93)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:335)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.felix.http.base.internal.handler.ServletHandler.init(ServletHandler.java:122)
at org.apache.felix.http.base.internal.handler.WhiteboardServletHandler.init(WhiteboardServletHandler.java:57)
at org.apache.felix.http.base.internal.registry.ServletRegistry.tryToActivate(ServletRegistry.java:358)
at org.apache.felix.http.base.internal.registry.ServletRegistry.addServlet(ServletRegistry.java:161)
What is the right way to solve my problem/handle the loading order?
- import org.glassfish.hk2.osgi-resource-locator into all bundles where i use Jersey?
- bundle-start levels?
- repacking org.glassfish.hk2.osgi-resource-locator into my server.base bundle?