quarkus: oracle driver and serialization conflict

Describe the bug

Starting in 2.2.2, adding some serialization code and the oracle driver in the same application will lead to a java.lang.IllegalStateException: Object serialization is currently not supported when attempting to serialize objects. This is working fine in 2.2.1.

Expected behavior

no regression. serialization code works as expected.

Actual behavior

2021-09-26 12:00:22,822 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-0) HTTP Request to /hello/serstring failed, error id: 9464a18a-f66a-4bdf-bf3a-79d81db36dea-1: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalStateException: Object serialization is currently not supported
        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$1.run(VertxRequestHandler.java:93)
        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:567)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.IllegalStateException: Object serialization is currently not supported
        at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:66)
        at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:381)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1135)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:349)
        at org.acme.getting.started.GreetingResource.serstring(GreetingResource.java:34)
        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:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 17 more

How to Reproduce?

create a sample application.

add the following dependency:

		<dependency>
			<groupId>io.quarkus</groupId>
			<artifactId>quarkus-jdbc-oracle</artifactId>
		</dependency>

add the following build args:

<quarkus.native.additional-build-args>--initialize-at-run-time=oracle.jdbc.datasource.impl.OracleDataSource,--allow-incomplete-classpath</quarkus.native.additional-build-args>

add the following service:

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/serstring")
    public String serstring() throws IOException, ClassNotFoundException {

        byte[] bytes = null;

        try (
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos)) {

            oos.writeObject("Hello RESTEasy");
            oos.flush();
            bytes = baos.toByteArray();
        }

        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                ObjectInputStream ois = new ObjectInputStream(bais)) {
            return (String) ois.readObject();
        }
    }

and the following test:

    @Test
    public void testser() {
        given()
                .when().get("/hello/serstring")
                .then()
                .statusCode(200)
                .body(is("Hello RESTEasy"));
    }

launch a native build, in 2.2.1 it works, in 2.2.2 it fails. it fails also on 2.3.0.CR1.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.2

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 22 (22 by maintainers)

Most upvoted comments

fyi, the issue has been reproduced by oracle support. a bug should be submitted soon to the dev team.

FYI, oracle support says: The development team has fixed the issue and they are working on the next steps to release the fix.

I missed it initially, but it is simply caused by:

@TargetClass(
    className = "java.io.ObjectStreamClass"
)
final class Target_java_io_ObjectStreamClass {
    @Substitute
    private Target_java_io_ObjectStreamClass() {
        throw new IllegalStateException("Object serialization is currently not supported");
    }

    @Substitute
    private Target_java_io_ObjectStreamClass(Class<?> var1) {
        throw new IllegalStateException("Object serialization is currently not supported");
    }
}

Is there any way we can work around this in Quarkus?