Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IllegalAnnotationException: Two classes have the same XML type name

I am developing web service under JBoss 5 and Java 1.6. What could possibly cause this exception? Below is my simplified web service code.

@Stateless @WebService() public class AccountWS {  @WebMethod() public CreateAccountResponse createAccount(@WebParam(name = "request") CreateAccountRequest request) {     return null; } 

And below is the full stack trace.

16:19:03,421 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/C:/Apps/jbdevstudio/jboss-eap/jboss-as/server/default/deploy/sif_esb.esb/ state=PreReal mode=Manual requiredState=Real org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/C:/Apps/jbdevstudio/jboss-eap/jboss-as/server/default/deploy/sif_esb.esb/ at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:177) at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1440) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1158) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1099) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1633) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:935) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1083) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:985) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:823) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:782) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702) at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117) at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70) at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53) at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1633) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:935) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1083) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:985) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:775) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540) at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256) at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461) at org.jboss.Main.boot(Main.java:221) at org.jboss.Main$1.run(Main.java:556) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalStateException: Cannot build JAXB context at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.createJAXBContext(JAXWSMetaDataBuilder.java:984) at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.buildWebServiceMetaData(JAXWSWebServiceMetaDataBuilder.java:151) at org.jboss.ws.metadata.builder.jaxws.JAXWSServerMetaDataBuilder.setupProviderOrWebService(JAXWSServerMetaDataBuilder.java:50) at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilderEJB3.buildMetaData(JAXWSMetaDataBuilderEJB3.java:76) at org.jboss.wsf.stack.jbws.UnifiedMetaDataDeploymentAspect.start(UnifiedMetaDataDeploymentAspect.java:69) at org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl.deploy(DeploymentAspectManagerImpl.java:129) at org.jboss.wsf.container.jboss50.deployer.ArchiveDeployerHook.deploy(ArchiveDeployerHook.java:76) at org.jboss.wsf.container.jboss50.deployer.AbstractWebServiceDeployer.internalDeploy(AbstractWebServiceDeployer.java:60) at org.jboss.wsf.container.jboss50.deployer.WebServiceDeployerEJB.internalDeploy(WebServiceDeployerEJB.java:113) at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50) at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171) ... 29 more Caused by: org.jboss.ws.WSException: Failed to create JAXBContext at org.jboss.ws.core.jaxws.CustomizableJAXBContextFactory.createContext(CustomizableJAXBContextFactory.java:114) at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.createJAXBContext(JAXWSMetaDataBuilder.java:980) ... 39 more Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "{http://kona.webservice.sif.unidata.com/}createAccountResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location:     at com.unidata.sif.kona.account.message.CreateAccountResponse     at private com.unidata.sif.kona.account.message.CreateAccountResponse com.unidata.sif.webservice.kona.jaxws.CreateAccountResponse._return     at com.unidata.sif.webservice.kona.jaxws.CreateAccountResponse this problem is related to the following location:     at com.unidata.sif.webservice.kona.jaxws.CreateAccountResponse  at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:448) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:297) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139) at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:105) at org.jboss.ws.core.jaxws.CustomizableJAXBContextFactory.createContext(CustomizableJAXBContextFactory.java:108) ... 40 more 
like image 850
Rosdi Kasim Avatar asked Nov 23 '10 09:11

Rosdi Kasim


1 Answers

I found the cause of my problem.

This problem occurs because JAX-WS generates a class for each method and the class name is constructed by concatenating methodName + "Response". In my case, the newly generated class by JAX-WS will have the same name as my response object.

Example:

@Stateless @WebService() public class AccountWS {      @WebMethod()     public CreateAccountResponse createAccount(@WebParam(name = "request") CreateAccountRequest request) {         return null;     } } 

JAX-WS will generate a new class CreateAccountResponse for Web Method createAccount which has the same name as the response object.

Solution:

Make sure that the name of the response object and method doesn't match. The same thing applies to the method parameter as well.

like image 194
Rosdi Kasim Avatar answered Sep 22 '22 12:09

Rosdi Kasim