Skip to content
New issue

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

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

Already on GitHub? # to your account

org.glassfish.hk2.osgi-resource-locator bundle did not acrivate in OSGi #359

Open
glassfishrobot opened this issue Jun 21, 2017 · 6 comments

Comments

@glassfishrobot
Copy link

Hi,

Reportet also here:
https://groups.google.com/forum/#!topic/bndtools-users/NuAmCd6sBaw
https://github.com/jersey/jersey/issues/3588

org.glassfish.hk2.osgi-resource-locator did not Activate properly. The bundle is in "Starting" status and did not Activate.

and because of that Jersey 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.(ApplicationHandler.java:282)
at org.glassfish.jersey.servlet.WebComponent.(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)

Example:
https://github.com/JohneDoe/osgi-sandbox
More Details:
https://groups.google.com/forum/#!topic/bndtools-users/NuAmCd6sBaw

@glassfishrobot
Copy link
Author

@jwells131313 Commented
I need more information than this. Is there a reason in a log somewhere for why the bundle did not start?

@glassfishrobot
Copy link
Author

@JohneDoe Commented
Karel Haeck explained it:
https://groups.google.com/forum/#!topic/bndtools-users/NuAmCd6sBaw

But i think a org.glassfish.hk2.osgi-resource-locator bundle should work by default and not with a workaround. Or do you think Jersey should handle it?

@glassfishrobot
Copy link
Author

@pjs102
Copy link

pjs102 commented Jan 2, 2019

Glassfish Version: 5.1.0-RC1
Jersey Version: 2.27.0

I’m trying to use the jersey client in Glassfish from an OSGI service and I’m seeing the same exception being thrown as listed above. There doesn’t appear to be any action on this (or the other) ticket to address the problem.

I’ve created a simple application that will reproduce the problem in the current Glassfish container. This can be downloaded and built from: https://github.com/pjs102/glassfish-5.1.0-bug-demos/tree/master/jersey-client-test

Please can you keen me informed of any progress.

Thanks
Paul

@mbooth101
Copy link
Contributor

FWIW, I see the same on Eclipse Equinox with Jersey 2.28 and HK2 2.5.0.

@cliffred
Copy link

cliffred commented Jun 12, 2019

I had the exact same problem. I also see that org.glassfish.hk2.osgi-resource-locator is in 'STARTING' state, but that's not the problem. The problem is that org.glassfish.jersey.core.jersey-common is not ACTIVE, instead it is only RESOLVED. Therefore in this code:

https://github.com/eclipse-ee4j/jersey/blob/a40169547a602a582f5fed1fd8ebe595ff2b83f7/core-common/src/main/java/org/glassfish/jersey/internal/OsgiRegistry.java#L93-L105

getBundleContext() returns null (only ACTIVE, STARTING, or STOPPING bundles have a BundleContext). Therefore setOSGiServiceFinderIteratorProvider() does not get invoked and ServiceFinder uses DefaultServiceIteratorProvider instead of OsgiServiceFinder. If you make sure org.glassfish.jersey.core.jersey-common is ACTIVE (via a start level in config.ini, or via the console, or programmatically) before you create the client it works.

I've also posted this analyses here: eclipse-ee4j/jersey#3588

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

No branches or pull requests

4 participants