Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

oracle driver and serialization conflict #34819

Closed
a483210 opened this issue Mar 30, 2023 · 8 comments
Closed

oracle driver and serialization conflict #34819

a483210 opened this issue Mar 30, 2023 · 8 comments
Labels
for: external-project For an external project and not something we can fix

Comments

@a483210
Copy link

a483210 commented Mar 30, 2023

Description

Introducing com.oracle.database.jdbc:ojdbc11:21.9.0.0 into the application and then packaging it as Native will result in a serialization error.

The error is consistent with quarkusio oracle driver and serialization conflict.

Cause of the error

The reason for the error is that there is a file oracle.nativeimage.Target_java_io_ObjectStreamClass in the oracle driver, which replaces the code of java.io.ObjectStreamClass during graalVM compilation.

Solution

In quarkus, there is a RemovedResourceBuildItem that can delete a class file of a certain Jar package before compilation. This is quarkus’s solution.

I haven’t found anything similar in SpringBoot yet, so I currently repackaged the oracle driver and uploaded it to my own maven repository.

Is there a more elegant solution in SpringBoot?

Exception prompt

Logging system failed to initialize using configuration from 'null'
java.lang.RuntimeException: Failed to load model from 'META-INF/spring/logback-model'
	at org.springframework.boot.logging.logback.SpringBootJoranConfigurator$ModelReader.read(SpringBootJoranConfigurator.java:318)
	at org.springframework.boot.logging.logback.SpringBootJoranConfigurator.configureUsingAotGeneratedArtifacts(SpringBootJoranConfigurator.java:114)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initializeFromAotGeneratedArtifactsIfPossible(LogbackLoggingSystem.java:210)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:187)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
	at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
	at [email protected]/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:352)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
	at com.psd.act.service.ActApplicationKt.main(ActApplication.kt:32)
Caused by: java.lang.IllegalStateException: Object serialization is currently not supported
	at [email protected]/java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:60)
	at [email protected]/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2017)
	at [email protected]/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1898)
	at [email protected]/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2224)
	at [email protected]/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1733)
	at [email protected]/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
	at [email protected]/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
	at org.springframework.boot.logging.logback.SpringBootJoranConfigurator$ModelReader.read(SpringBootJoranConfigurator.java:312)
	... 23 more

Environment

  • Spring Boot version number: 3.0.2
  • GraalVM version number: graalvm64-ce-17.0.5-22.3.0
  • OracleDriver version number: com.oracle.database.jdbc:ojdbc11:21.9.0.0
  • Operating system information: MacOS

Steps to reproduce

  • 1.Create a new Spring Boot project and add Oracle database dependencies;
  • 2.Configure Oracle database connection and use Oracle database Driver;
  • 3.Build the application into a Native image;
  • 4.Start the Native image and the above error message appears.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 30, 2023
@damianopittori
Copy link

Hello,

I was about to open the same bug today 😄

My solution, other then 'repackaged the oracle driver', was to downgrade the ojdbc version to 21.1.0.0, since the class performing that substitution was introduced in v21.3.0.0.

Here's a repo to replicate the issue (don't need to use the ojdbc, just being in the classpath toghether with spring-boot-starter-logging and using a logback.xml or logback-spring.xml) : spring-native-ojdbc

Environment

  • Spring Boot version number: 3.0.5
  • GraalVM version number: GraalVM CE 22.3.1
  • OracleDriver version number: com.oracle.database.jdbc:ojdbc11:21.7.0.0
  • Operating system information: Oracle Linux Server 8.7

@snicoll
Copy link
Member

snicoll commented Apr 4, 2023

@damianopittori thanks for the sample.

@a483210 this is an issue in the Oracle driver that disables core JDK features via a substitution. There's nothing we can do about it. I'll do my best to share the issue but if you have a support contract, please report it as well.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2023
@snicoll snicoll added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 4, 2023
@damianopittori
Copy link

The issue has been fixed in the latest version of the Oracle driver com.oracle.database.jdbc:ojdbc11:23.2.0.0 released on April 07, 2023.

@snicoll
Copy link
Member

snicoll commented Apr 11, 2023

@damianopittori thanks. I also got in touch with the team at Oracle and they will backport the fix to 21.9 if I understood correctly.

@maradanasai
Copy link

@snicoll Even with 21.9 version, able to reproduce this issue.

I'm using spring boot 3.2.2 and native-image-community:21-ol8 jdk version

@wilkinsona
Copy link
Member

@maradanasai Oracle may not yet have back ported the fix to 21.9, we don't know. You'll have to ask Oracle for up-to-date information on the status of any back port.

@maradanasai
Copy link

Got it @wilkinsona Are there any work arounds to get it fixed temporarily?

@wilkinsona
Copy link
Member

@a483210 describes their approach above. You may want to try doing the same. Beyond that, you may want to ask the GraalVM community if it's possible to ignore a substitution or to reverse a substitution's effects so that serialization isn't disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

6 participants