Repository: quarkusio/quarkus
Issue: native compilation : quarkus-jdbc-oracle with elasticsearch-java strange behaviour

### Describe the bug

Hello,

I'm trying to compile in native mode my project using   

- quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3-java17 as nativeBuilder
- quarkus 2.16.3.Final
-  quarkus-jdbc-oracle 
-  quarkus-elasticsearch-rest-client
- elasticsearch-java

But it fail.

I can't figure out the problem. I've tried to add  --initialize-at-run-time  args but it doesn't change anything.

I'm already using elasticsearch-java in native mode (8.1.2 not 8.6.2) with some initialize-at-run-time and register for reflection it works but the problem seem to come from the jdbc-oracle.

### Expected behavior

Compilation without error or at least not the oracle-jdbc one.

### Actual behavior

With the actual configuration I get this error :

```
#15 766.0 Error: Classes that should be initialized at run time got initialized during image building:
#15 766.0  oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser the class was requested to be initialized at run time (from feature io.quarkus.runner.Feature.beforeAnalysis with 'BlockSource$ThreadedCachingBlockSource$BlockReleaser.class'). oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource caused initialization of this class with the following trace:
```
More detail stack on the project readme : https://github.com/xrobert35/quarkus-oracle-jdbc-error-example/blob/master/README.md

### How to Reproduce?

I've made a simplified project to reproduce 

Step 1.
```shell
https://github.com/xrobert35/quarkus-oracle-jdbc-error-example
docker build -t <name> . --no-cache
```

### Output of `uname -a` or `ver`

docker windows or WSL docker

### Output of `java -version`

Java Version 17.0.6+10-jvmci-22.3-b13

### GraalVM version (if different from Java)

22.3

### Quarkus version or git rev

2.16.3.Final

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

Docker

### Additional information

### Some strange behaviour

- If you remove the use of ElasticsearchClient (including the import) in  TestService **the compilation will work**. (So I suppose the real problem could be the creation of the ElasticsearchClient (in the TestOracleJDBCConfig file),  but : 
- If you change quarkus-jdbc-oracle to quarkus-jdbc-postgresql and change to db-king to postgresql and I let the ElasticsearchClient  **the compilation will work**

Changed files:
extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java
extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java

diff --git a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java
index fbabaecceb2..892ef190c53 100644
--- a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java
+++ b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleMetadataOverrides.java
@@ -9,6 +9,7 @@
 import io.quarkus.deployment.builditem.nativeimage.NativeImageAllowIncompleteClasspathBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
 import io.quarkus.maven.dependency.ArtifactKey;
 
 /**
@@ -66,7 +67,8 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
     }
 
     @BuildStep
-    void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized) {
+    void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized,
+            BuildProducer<RuntimeReinitializedClassBuildItem> runtimeReinitialized) {
         //These re-implement all the "--initialize-at-build-time" arguments found in the native-image.properties :
 
         // Override: the original metadata marks the drivers as "runtime initialized" but this makes it incompatible with
@@ -93,10 +95,14 @@ void runtimeInitializeDriver(BuildProducer<RuntimeInitializedClassBuildItem> run
         runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.net.nt.TcpMultiplexer"));
         runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.net.nt.TcpMultiplexer"));
         runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.net.nt.TcpMultiplexer$LazyHolder"));
-        runtimeInitialized
-                .produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource"));
-        runtimeInitialized.produce(new RuntimeInitializedClassBuildItem(
+
+        // Needs to be REinitialized to avoid problems when also using the Elasticsearch Java client
+        // See https://github.com/quarkusio/quarkus/issues/31624#issuecomment-1457706253
+        runtimeReinitialized.produce(new RuntimeReinitializedClassBuildItem(
+                "oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource"));
+        runtimeReinitialized.produce(new RuntimeReinitializedClassBuildItem(
                 "oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser"));
+
         runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.xa.client.OracleXADataSource"));
         runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.replay.OracleXADataSourceImpl"));
         runtimeInitialized.produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.datasource.OracleXAConnection"));
diff --git a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java
index 8778e677ca1..51053a2fb07 100644
--- a/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java
+++ b/extensions/jdbc/jdbc-oracle/deployment/src/main/java/io/quarkus/jdbc/oracle/deployment/OracleNativeImage.java
@@ -3,7 +3,6 @@
 import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
-import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
 
 /**
  * @author Sanne Grinovero <sanne@hibernate.org>
@@ -35,10 +34,4 @@ void reflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
         reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "com.sun.jndi.rmi.registry.RegistryContextFactory"));
     }
 
-    @BuildStep
-    void runtimeInitialization(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClass) {
-        runtimeInitializedClass
-                .produce(new RuntimeInitializedClassBuildItem("oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource"));
-    }
-
 }