eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:
https://github.com/eclipse-ee4j/jersey/wiki
Other
691 stars 357 forks source link

HK2 service reification failed #3538

Open jerseyrobot opened 7 years ago

jerseyrobot commented 7 years ago

jersey hk2 guice integration results this warning in logs

WARNING: The following warnings have been detected:
WARNING: HK2 service reification failed for [com.igorbunova.handler.Hello] with an exception:
MultiException stack 1 of 2
java.lang.NoSuchMethodException: Could not find a suitable constructor in com.igorbunova.handler.Hello class.
    at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:192)
    at org.jvnet.hk2.internal.Utilities.getConstructor(Utilities.java:178)
    at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:129)
    at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:180)
    at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:740)
    at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:694)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:461)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2288)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.igdCacheCompute(ServiceLocatorImpl.java:1164)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.access$400(ServiceLocatorImpl.java:125)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$8.compute(ServiceLocatorImpl.java:1158)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$8.compute(ServiceLocatorImpl.java:1155)
    at org.glassfish.hk2.utilities.cache.internal.WeakCARCacheImpl.compute(WeakCARCacheImpl.java:116)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetDescriptor(ServiceLocatorImpl.java:1238)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:770)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:737)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:707)
    at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:172)
    at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:284)
    at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:74)
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:109)
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
    at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:112)
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:92)
    at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:61)
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:318)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)

Affected Versions

[2.26-b03]

jerseyrobot commented 6 years ago
jerseyrobot commented 7 years ago

@glassfishrobot Commented Reported by igorbunova

jerseyrobot commented 7 years ago

@glassfishrobot Commented igorbunova said: here is my code project https://github.com/igorbunova/jersey2-guice-integration

I tried these combinations of versions

| jersey | guice | hk2 | hk2-guice | result | | 2.25.1 | 4.0 | 2.4.0 | 2.4.0 | Starts, works with warning | | 2.25.1 | 4.0 | 2.3.0 | 2.3.0 | Starts, works with warning | | 2.25.1 | 4.0 | 2.2.0 | 2.2.0 | Doesn't start | | 2.7 | 4.0 | 2.2.0 | 2.2.0 | Starts, doesn't work |

jerseyrobot commented 7 years ago

@glassfishrobot Commented @jwells131313 said: This seems like an issue with the JerseyClassAnalyzer

jerseyrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-3266

jerseyrobot commented 7 years ago

@vnagarajan-liaison-com Commented Any updates on this? I see the same issue with version 2.25.1 and 2.7

jerseyrobot commented 7 years ago

@vnagarajan-liaison-com Commented Any workaround to get rid of this issue?

jerseyrobot commented 7 years ago

@doyouevensunbro Commented Would love to know the issue and/or workaround.

jerseyrobot commented 7 years ago

@airdrik Commented I ran into this issue as well. Jersey 2.23, Guice 4.1.0, HK2 & Guice-bridge 2.4.0

I tried replacing guice's Inject with javax.inject.Inject throughout my app and the HK2 warnings went away.

jerseyrobot commented 7 years ago

@blling Commented Should anyone help out #3692 ? It will solve this problem.

jerseyrobot commented 7 years ago

@doyouevensunbro Commented @blling I'm not using Guice and I had this problem. What it turned out to be was that if HK2 has any issues at all it will just throw this error. For me I had an issue with my custom ExceptionMapper Provider. Fixed that and the error went away.

Hope this helps.

codersky commented 6 years ago

any updates for this bug, is it fixed now or not? thanks