gitlab4j-api icon indicating copy to clipboard operation
gitlab4j-api copied to clipboard

Error using gitlab4j-api in native quarkus image

Open vindevoy opened this issue 4 years ago • 4 comments
trafficstars

Hi,

The library has been used to connect Rundeck to Gitlab in a small Java project that uses Quarkus and GraalVM. It simply returns some basic info (like tags and branches, the current user) and this all works EXCEPT when you build a native image and try to connect. Then there's an error about the InjectionManagerFactory not found.

Problem arises only when using the native image, not the fatjar, ...

2021-03-22 10:50:45,897 INFO [io.quarkus] (main) rundeck-gitlab-connector 1.6.0-SNAPSHOT native (powered by Quarkus 1.12.2.Final) started in 0.597s. Listening on: http://0.0.0.0:8080 2021-03-22 10:50:45,898 INFO [io.quarkus] (main) Profile prod activated. 2021-03-22 10:50:45,898 INFO [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jackson] 2021-03-22 10:51:12,157 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /user failed, error id: 510aee19-778b-4323-b991-c93d1408bbd1-1: org.jboss.resteasy.spi.UnhandledException: org.gitlab4j.api.GitLabApiException: InjectionManagerFactory not found. at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106) at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372) at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261) at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161) at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364) at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247) at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:41) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93) at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452) at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29) at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29) at java.lang.Thread.run(Thread.java:834) at org.jboss.threads.JBossThread.run(JBossThread.java:501) at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519) at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138) Caused by: org.gitlab4j.api.GitLabApiException: InjectionManagerFactory not found. at org.gitlab4j.api.AbstractApi.handle(AbstractApi.java:655) at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:215) at org.gitlab4j.api.UserApi.getCurrentUser(UserApi.java:670) at online.vindevoy.foss.rundeckGitlabConnector.services.UserService.getCurrentUser(UserService.java:16) at online.vindevoy.foss.rundeckGitlabConnector.services.UserService_ClientProxy.getCurrentUser(UserService_ClientProxy.zig:188) at online.vindevoy.foss.rundeckGitlabConnector.resources.UserResource.user(UserResource.java:22) at java.lang.reflect.Method.invoke(Method.java:566) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130) at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:643) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:507) at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:457) at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:459) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:419) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:393) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:68) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492) ... 17 more Caused by: java.lang.IllegalStateException: InjectionManagerFactory not found. at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:74) at java.util.Optional.orElseThrow(Optional.java:408) at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:74) at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:44) at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:412) at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:317) at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:807) at org.glassfish.jersey.client.ClientRequest.getClientRuntime(ClientRequest.java:219) at org.glassfish.jersey.client.ClientRequest.getInjectionManager(ClientRequest.java:610) at org.glassfish.jersey.client.JerseyWebTarget.onBuilder(JerseyWebTarget.java:364) at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:192) at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:36) at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:796) at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:761) at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:412) at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:400) at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:213) ... 33 more

vindevoy avatar Mar 22 '21 09:03 vindevoy

Yeah, I have a similar problem.

flon-chou avatar Apr 19 '22 07:04 flon-chou

I did not have time to work on this topic. If you can find a way to fix this, I can review PRs.

jabby avatar Apr 19 '22 10:04 jabby

InjectionManagerFactory is a class that belongs to the Jersey client that this lib is using. I guess in the Quarkus world it would be better to use the HTTP client they provide: smallrye-rest-client.

There is an open issue to discuss what should happen with the HTTP client used in this lib: https://github.com/gitlab4j/gitlab4j-api/issues/924 --> Nothing is decided so far. Feel free to join the discussion.

For the issue mentioned here, a quick search pointed to following issue: https://github.com/quarkusio/quarkus/issues/1647#issuecomment-500897313 --> Somebody computed the GraalVM instructions in order to have the Jersey reflection working at runtime in the native mode.


It would be interesting to know if this issue has evolved with the 6.0.0-rc.1 version where we are now using a newer version of Jersey 3.1.1 (using the jakarta.* namespace instead of javax.*). Probably you also need to update to Quarkus 3 in order to use this version.

jmini avatar Apr 13 '23 13:04 jmini

I am not sure if this is enough for your use case, but @nilchina proposed following change: #1074

jmini avatar Dec 21 '23 12:12 jmini