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

llegalAnnotationExceptions: Two classes have the same XML type name #1418

Closed
argenstijn opened this issue Jun 21, 2024 · 4 comments
Closed

Comments

@argenstijn
Copy link

argenstijn commented Jun 21, 2024

I got the following exception when marshalling object to a string:

org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://www.w3.org/2005/08/addressing}EndpointReferenceType". Use @XmlType.name and @XmlType.namespace to assign different names to them.
	this problem is related to the following location:
		at jakarta.xml.ws.wsaddressing.W3CEndpointReference
	this problem is related to the following location:
		at org.apache.cxf.ws.addressing.EndpointReferenceType
: java.lang.RuntimeException: org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://www.w3.org/2005/08/addressing}EndpointReferenceType". Use @XmlType.name and @XmlType.namespace to assign different names to them.
	this problem is related to the following location:
		at jakarta.xml.ws.wsaddressing.W3CEndpointReference
	this problem is related to the following location:
		at org.apache.cxf.ws.addressing.EndpointReferenceType

	at io.quarkus.jaxb.runtime.JaxbContextProducer.createJAXBContext(JaxbContextProducer.java:82)
	at io.quarkus.jaxb.runtime.JaxbContextProducer.jaxbContext(JaxbContextProducer.java:31)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_am0gJyME7dZMe9-jXj7V1ZcaOUk_Bean.doCreate(Unknown Source)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_am0gJyME7dZMe9-jXj7V1ZcaOUk_Bean.create(Unknown Source)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_am0gJyME7dZMe9-jXj7V1ZcaOUk_Bean.create(Unknown Source)
	at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:119)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:38)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:35)
	at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:32)
	at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
	at io.quarkus.arc.impl.ComputingCacheContextInstances.computeIfAbsent(ComputingCacheContextInstances.java:19)
	at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:35)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_am0gJyME7dZMe9-jXj7V1ZcaOUk_Bean.get(Unknown Source)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_am0gJyME7dZMe9-jXj7V1ZcaOUk_Bean.get(Unknown Source)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_mhm6a2ORgIv7dGY8nQRNQSqNJ9Y_Bean.doCreate(Unknown Source)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_mhm6a2ORgIv7dGY8nQRNQSqNJ9Y_Bean.create(Unknown Source)
	at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_mhm6a2ORgIv7dGY8nQRNQSqNJ9Y_Bean.create(Unknown Source)
	at io.quarkus.arc.impl.RequestContext$1.get(RequestContext.java:79)
	at io.quarkus.arc.impl.RequestContext$1.get(RequestContext.java:75)
	at io.quarkus.arc.generator.Default_jakarta_enterprise_context_RequestScoped_ContextInstances.c4(Unknown Source)
	at io.quarkus.arc.generator.Default_jakarta_enterprise_context_RequestScoped_ContextInstances.computeIfAbsent(Unknown Source)
	at io.quarkus.arc.impl.RequestContext.getIfActive(RequestContext.java:75)
	at io.quarkus.arc.impl.ClientProxies.getSingleContextDelegate(ClientProxies.java:28)
	at jakarta.xml.bind.JaxbContextProducer_ProducerMethod_marshaller_mhm6a2ORgIv7dGY8nQRNQSqNJ9Y_ClientProxy.arc$delegate(Unknown Source)
	at jakarta.xml.bind.JaxbContextProducer_ProducerMethod_marshaller_mhm6a2ORgIv7dGY8nQRNQSqNJ9Y_ClientProxy.marshal(Unknown Source)
	at com.nn.aav.insurance.business.customers.boundary.policyadministration.CustomersStore.validResponse(CustomersStore.java:58)
	at com.nn.aav.insurance.business.customers.boundary.policyadministration.CustomersStore.createOrUpdate(CustomersStore.java:43)
	at com.nn.aav.insurance.business.customers.boundary.policyadministration.CustomersStore_ClientProxy.createOrUpdate(Unknown Source)
	at com.nn.aav.insurance.business.customers.boundary.CustomersResource.createOrUpdate(CustomersResource.java:61)
	at com.nn.aav.insurance.business.customers.boundary.CustomersResource_Subclass.createOrUpdate$$superforward(Unknown Source)
	at com.nn.aav.insurance.business.customers.boundary.CustomersResource_Subclass$$function$$1.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:73)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:62)
	at io.quarkus.hibernate.validator.runtime.interceptor.AbstractMethodValidationInterceptor.validateMethodInvocation(AbstractMethodValidationInterceptor.java:71)
	at io.quarkus.hibernate.validator.runtime.jaxrs.ResteasyReactiveEndPointValidationInterceptor.validateMethodInvocation(ResteasyReactiveEndPointValidationInterceptor.java:21)
	at io.quarkus.hibernate.validator.runtime.jaxrs.ResteasyReactiveEndPointValidationInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:30)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:27)
	at com.nn.aav.insurance.business.customers.boundary.CustomersResource_Subclass.createOrUpdate(Unknown Source)
	at com.nn.aav.insurance.business.customers.boundary.CustomersResource$quarkusrestinvoker$createOrUpdate_f481820868dbc58995edff6a410c8d38b154d171.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:599)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.glassfish.jaxb.runtime.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://www.w3.org/2005/08/addressing}EndpointReferenceType". Use @XmlType.name and @XmlType.namespace to assign different names to them.
	this problem is related to the following location:
		at jakarta.xml.ws.wsaddressing.W3CEndpointReference
	this problem is related to the following location:
		at org.apache.cxf.ws.addressing.EndpointReferenceType

	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:373)
	at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
	at io.quarkus.jaxb.runtime.JaxbContextProducer.createJAXBContext(JaxbContextProducer.java:80)
	... 51 more

version: quarkus-cxf-bom version 3.11.3

@argenstijn
Copy link
Author

Any idea why?

ps i used

org.apache.cxf
cxf-codegen-plugin
4.0.4

to generate my java code!

@argenstijn
Copy link
Author

quarkus.jaxb.exclude-classes=jakarta.xml.ws.wsaddressing.W3CEndpointReference

Will fix the problem. But is this necessary?

@ppalaga
Copy link
Contributor

ppalaga commented Jun 23, 2024

Hi @argenstijn, thanks for the report. What happens here is that Quarkus CXF extensions bring classes into your application which Quarkus default JAXBContext considers conflicting. The problem is described in detail in quarkusio/quarkus#31646.

I think you should decide how to proceed as follows:

  1. Do you need to access the default JAXBContext for the sake of JAXB processing in your REST endpoints? If not, remove all JAXBContext injection points and the problem may disappear.
  2. If you need the default JAXBContext and you care for the consistency of the classes it sees, you should use quarkus.jaxb.exclude-classes to exclude classes you want the default context to ignore. You should know which classes/packages the default context needs to see. See also https://quarkus.io/guides/rest#xml-serialisation
  3. If you need the default JAXBContext and you think all the conflicts do not matter, because you are sure the context will never ever have to handle any of the conflicting classes, you may want to set quarkus.jaxb.validate-jaxb-context = false. This might be rather risky and you should prefer 2. as far as possible.

@ppalaga
Copy link
Contributor

ppalaga commented Jun 25, 2024

@argenstijn feel free to reopen if there is still something unclear.

@ppalaga ppalaga closed this as completed Jun 25, 2024
@ppalaga ppalaga added this to the no fix/won't fix milestone Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants