Repository: quarkusio/quarkus
Issue: Two classes have the same XML type name "xmlObject".

After upgrading from 2.16.2 to 3.0.1 I'm getting the exception below when running tests with quarkus dev. Every first tests round are complete without trouble. But when the tests are run again, they keep failing until I stop dev mode and start it again. 

The exception occurs while testing a process that uses a RestClient which consumes XML. I'm using Wiremock to create the endpoint.

<pre>
        at io.restassured.internal.ValidatableResponseOptionsImpl.statusCode(ValidatableResponseOptionsImpl.java:89)
        at org.acme.ExampleResourceTest.testHelloEndpoint(ExampleResourceTest.java:19)
        Suppressed: java.lang.RuntimeException: org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "xmlObject". Use @XmlType.name and @XmlType.namespace to assign different names to them.
        this problem is related to the following location:
                at org.acme.XmlObject
        this problem is related to the following location:
                at org.acme.XmlObject

                at io.quarkus.jaxb.runtime.JaxbContextProducer.createJAXBContext(JaxbContextProducer.java:80)
                at io.quarkus.jaxb.runtime.JaxbContextProducer.jaxbContext(JaxbContextProducer.java:29)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_6a6d20272304edd64c7bdfa35e3ed5d5971a3949_Bean.doCreate(Unknown Source)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_6a6d20272304edd64c7bdfa35e3ed5d5971a3949_Bean.create(Unknown Source)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_6a6d20272304edd64c7bdfa35e3ed5d5971a3949_Bean.create(Unknown Source)
                at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
                at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
                at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
                at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
                at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
                at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_6a6d20272304edd64c7bdfa35e3ed5d5971a3949_Bean.get(Unknown Source)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_6a6d20272304edd64c7bdfa35e3ed5d5971a3949_Bean.get(Unknown Source)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_9a19ba6b6391808bfb74663c9d044d412a8d27d6_Bean.doCreate(Unknown Source)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_9a19ba6b6391808bfb74663c9d044d412a8d27d6_Bean.create(Unknown Source)
                at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_9a19ba6b6391808bfb74663c9d044d412a8d27d6_Bean.create(Unknown Source)
                at io.quarkus.arc.impl.RequestContext.getIfActive(RequestContext.java:74)
                at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:30)
                at jakarta.xml.bind.JaxbContextProducer_ProducerMethod_marshaller_9a19ba6b6391808bfb74663c9d044d412a8d27d6_ClientProxy.arc$delegate(Unknown Source)
                at jakarta.xml.bind.JaxbContextProducer_ProducerMethod_marshaller_9a19ba6b6391808bfb74663c9d044d412a8d27d6_ClientProxy.marshal(Unknown Source)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter.marshal(ClientMessageBodyWriter.java:56)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter_Subclass.marshal$$superforward(Unknown Source)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter_Subclass$$function$$3.apply(Unknown Source)
                at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:74)
                at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:63)
                at io.quarkus.arc.impl.ActivateRequestContextInterceptor.invoke(ActivateRequestContextInterceptor.java:124)
                at io.quarkus.arc.impl.ActivateRequestContextInterceptor.aroundInvoke(ActivateRequestContextInterceptor.java:33)
                at io.quarkus.arc.impl.ActivateRequestContextInterceptor_Bean.intercept(Unknown Source)
                at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
                at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:38)
                at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:26)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter_Subclass.marshal(Unknown Source)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter.writeTo(ClientMessageBodyWriter.java:37)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter_Subclass.writeTo$$superforward(Unknown Source)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter_Subclass$$function$$4.apply(Unknown Source)
                at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:74)
                at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:63)
                at io.quarkus.arc.impl.ActivateRequestContextInterceptor.invoke(ActivateRequestContextInterceptor.java:124)
                at io.quarkus.arc.impl.ActivateRequestContextInterceptor.aroundInvoke(ActivateRequestContextInterceptor.java:33)
                at io.quarkus.arc.impl.ActivateRequestContextInterceptor_Bean.intercept(Unknown Source)
                at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
                at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:38)
                at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:26)
                at io.quarkus.rest.client.reactive.jaxb.runtime.ClientMessageBodyWriter_Subclass.writeTo(Unknown Source)
                at org.jboss.resteasy.reactive.client.impl.ClientSerialisers.invokeClientWriter(ClientSerialisers.java:126)
                at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext.writeEntity(RestClientRequestContext.java:265)
                at org.jboss.resteasy.reactive.client.handlers.ClientSendRequestHandler.setRequestHeadersAndPrepareBody(ClientSendRequestHandler.java:525)
                at org.jboss.resteasy.reactive.client.handlers.ClientSendRequestHandler$2.accept(ClientSendRequestHandler.java:196)
                at org.jboss.resteasy.reactive.client.handlers.ClientSendRequestHandler$2.accept(ClientSendRequestHandler.java:117)
                at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
                at io.smallrye.mutiny.helpers.UniCallbackSubscriber.onItem(UniCallbackSubscriber.java:73)
                at io.smallrye.mutiny.operators.uni.UniOperatorProcessor.onItem(UniOperatorProcessor.java:47)
                at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:60)
                at org.jboss.resteasy.reactive.client.AsyncResultUni.lambda$subscribe$1(AsyncResultUni.java:35)
                at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
                at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
                at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
                at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23)
                at io.vertx.core.http.impl.HttpClientImpl.lambda$null$5(HttpClientImpl.java:683)
                at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
                at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54)
                at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:86)
                at io.vertx.core.impl.DuplicatedContext.execute(DuplicatedContext.java:163)
                at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:51)
                at io.vertx.core.impl.future.FutureImpl.addListener(FutureImpl.java:196)
                at io.vertx.core.impl.future.PromiseImpl.addListener(PromiseImpl.java:23)
                at io.vertx.core.impl.future.FutureImpl.onComplete(FutureImpl.java:164)
                at io.vertx.core.impl.future.PromiseImpl.onComplete(PromiseImpl.java:23)
                at io.vertx.core.http.impl.Http1xClientConnection.createStream(Http1xClientConnection.java:1270)
                at io.vertx.core.http.impl.HttpClientImpl.lambda$doRequest$6(HttpClientImpl.java:666)
                at io.verpl.pool.Endpoint.lambda$getConnection$0(Endpoint.java:52)
                at io.vertx.core.http.impl.SharedClientHttpStreamEndpoint$Request.handle(SharedClientHttpStreamEndpoint.java:162)
                at io.vertx.core.http.impl.SharedClientHttpStreamEndpoint$Request.handle(SharedClientHttpStreamEndpoint.java:123)
                at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:55)
                at io.vertx.core.impl.ContextBase.emit(ContextBase.java:239)
                at io.vertx.core.net.impl.pool.SimpleConnectionPool$LeaseImpl.emit(SimpleConnectionPool.java:704)
                at io.vertx.core.net.impl.pool.SimpleConnectionPool$ConnectSuccess$2.run(SimpleConnectionPool.java:338)
                at io.vertx.core.net.impl.pool.CombinerExecutor.submit(CombinerExecutor.java:56)
                at io.vertx.core.net.impl.pool.SimpleConnectionPool.execute(SimpleConnectionPool.java:245)
                at io.vertx.core.net.impl.pool.SimpleConnectionPool.lambda$connect$2(SimpleConnectionPool.java:257)
                at io.vertx.core.http.impl.SharedClientHttpStreamEndpoint.lambda$connect$2(SharedClientHttpStreamEndpoint.java:102)
                at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141)
                at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
                at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
                at io.vertx.core.impl.future.Composition$1.onSuccess(Composition.java:62)
                at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
                at io.vertx.core.impl.future.FutureImpl.addListener(FutureImpl.java:196)
                at io.vertx.core.impl.future.PromiseImpl.addListener(PromiseImpl.java:23)
                at io.vertx.core.impl.future.Composition.onSuccess(Composition.java:43)
                at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:60)
                at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
                at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23)
                at io.vertx.core.Promise.complete(Promise.java:66)
                at io.vertx.core.net.impl.NetClientImpl.lambda$connected$9(NetClientImpl.java:330)
                at io.vertx.core.net.impl.VertxHandler.setConnection(VertxHandler.java:82)
                at io.vertx.core.net.impl.VertxHandler.handlerAdded(VertxHandler.java:88)
                at io.netty.channel.AbstractChannelHandlerContext.callHandlerAdded(AbstractChannelHandlerContext.java:1114)
                at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:609)
                at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:223)
                at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:195)
                at io.vertx.core.net.impl.NetClientImpl.connected(NetClientImpl.java:332)
                at io.vertx.core.net.impl.NetClientImpl.lambda$connectInternal2$3(NetClientImpl.java:294)
                at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264)
                at io.vertx.core.net.impl.ChannelProvider.connected(ChannelProvider.java:172)
                at io.vertx.core.net.impl.ChannelProvider.lambda$handleConnect$0(ChannelProvider.java:155)
                at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:590)
                at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:583)
                at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:559)
                at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:492)
                at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:636)
                at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:625)
                at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:105)
                at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84)
                at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:300)
                at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:335)
                at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
                at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
                at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
                at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
                at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
                at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
                at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
                at java.base/java.lang.Thread.run(Thread.java:833)
        Caused by: org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "xmlObject". Use @XmlType.name and @XmlType.namespace to assign different names to them.
        this problem is related to the following location:
                at org.acme.XmlObject
        this problem is related to the following location:
                at org.acme.XmlObject

                at org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:83)
                at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:421)
                at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:255)
                at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115)
                at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144)
                at org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:44)
                at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:368)
                at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
                at io.quarkus.jaxb.runtime.JaxbContextProducer.createJAXBContext(JaxbContextProducer.java:78)
                ... 122 more

</pre>

### Expected behavior

The test should continue to pass

### Actual behavior

After the first execution, the test fails.

### How to Reproduce?

1. Create a XML consumer RestClient
2. Mock the responding endpoint with Wiremock
3. Create a Test that uses this RestClient
4. Execute quarkus dev and start the tests
5. Run the test again to see the exception

### Output of `uname -a` or `ver`

Linux 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

### Output of `java -version`

openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment (build 17.0.7+7-Ubuntu-0ubuntu122.04.2)                   OpenJDK 64-Bit Server VM (build 17.0.7+7-Ubuntu-0ubuntu122.04.2, mixed mode, sharing)

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

3.0.1

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Apache Maven 3.6.3 Maven home: /usr/share/maven Java version: 17.0.7, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "5.15.90.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"

### Additional information

_No response_

Changed files:
extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java
extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextConfigRecorder.java
extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextProducer.java

diff --git a/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java b/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java
index 22ce22a0d46..17768f6d8e6 100644
--- a/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java
+++ b/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java
@@ -322,6 +322,7 @@ void bindClassesToJaxbContext(
             SynthesisFinishedBuildItem beanContainerState,
             JaxbContextConfigRecorder jaxbContextConfig /* Force the build time container to invoke this method */) {
 
+        jaxbContextConfig.reset();
         final BeanResolver beanResolver = beanContainerState.getBeanResolver();
         final Set<BeanInfo> beans = beanResolver
                 .resolveBeans(Type.create(DotName.createSimple(JAXBContext.class), org.jboss.jandex.Type.Kind.CLASS));
diff --git a/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextConfigRecorder.java b/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextConfigRecorder.java
index 30ef87780cd..f0a6e4587a5 100644
--- a/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextConfigRecorder.java
+++ b/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextConfigRecorder.java
@@ -15,6 +15,10 @@ public void addClassesToBeBound(Collection<Class<?>> classes) {
         this.classesToBeBound.addAll(classes);
     }
 
+    public void reset() {
+        classesToBeBound.clear();
+    }
+
     public static Set<Class<?>> getClassesToBeBound() {
         return Collections.unmodifiableSet(classesToBeBound);
     }
diff --git a/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextProducer.java b/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextProducer.java
index 8bfb0c6f1af..3b2dbc7cf4c 100644
--- a/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextProducer.java
+++ b/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbContextProducer.java
@@ -4,8 +4,10 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import jakarta.enterprise.context.ApplicationScoped;
 import jakarta.enterprise.context.RequestScoped;
@@ -71,7 +73,7 @@ public JAXBContext createJAXBContext(Instance<JaxbContextCustomizer> customizers
                 customizer.customizeContextProperties(properties);
             }
 
-            List<Class> classes = new ArrayList<>();
+            Set<Class> classes = new HashSet<>();
             classes.addAll(Arrays.asList(extraClasses));
             classes.addAll(JaxbContextConfigRecorder.getClassesToBeBound());