Search code examples
javajerseyglassfishnativequarkus

Quarkus native mode - org.glassfish.jersey.internal.RuntimeDelegateImpl Class not found


I'm using Quarkus 2.6.0 in native mode, using Quarkus to make CXF calls and return those results in JSON format, so I'm using resteasy and resteasy-jackson.

        <dependency>
            <groupId>io.quarkiverse.cxf</groupId>
            <artifactId>quarkus-cxf</artifactId>
            <version>0.11.0</version>
        </dependency>

The service is compiled and executed in Native mode and during a normal day the service supports around 1.5M requests. But a few of them (probably between 5 and 10), the services raises this error and I don't know why (and worst of all, I can't reproduce it in a local environment)

I'm not sure if discovering that class in the reflection config files will resolve the problem (I'll give a try).

Any ideas?

java.lang.RuntimeException: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
    at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:129)
    at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:96)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.getInstance(ResteasyProviderFactory.java:117)
    at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:82)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:829)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:600)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl
    at java.lang.Class.forName(DynamicHub.java:1347)
    at java.lang.Class.forName(DynamicHub.java:1322)
    at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:93)
    at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:210)
    at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:111)

I don't know if it's an important point, but we have Horizontal Pod Autoscaling, and during the day, the number of pods fluctuate.

More evidencies: enter image description here

enter image description here


Solution

  • Finally, I've solved the problem. The problem was that we have a small amount of time in the terminationGracePeriodSeconds variable (in our case, 5 sec).

    So K8S kills the pod and the last request failed (I suppose that some beans can't be instantiated and that was the reason that it raises a RuntimeException).

    We have increased that period, and the problem was solved.

    Thx.