我正在JBoss 5和Java 1.6下开发Web服务。什么可能导致这个异常?下面是我简化的Web服务代码。
@Stateless
@WebService()
public class AccountWS {
@WebMethod()
public CreateAccountResponse createAccount(@WebParam(name = "request") CreateAccountRequest request) {
return null;
}
下面是完整的堆栈跟踪。
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
4条答案
按热度按时间xienkqul1#
我找到了问题的根源。
出现此问题的原因是,JAX-WS为每个方法生成一个类,并且类名是通过连接
methodName
+"Response"
来构造的。在我的示例中,JAX-WS新生成的类将与我的响应对象具有相同的名称。示例:
JAX-WS将为Web方法
createAccount
生成一个新类CreateAccountResponse
,它与响应对象具有相同的名称。解决方法:
确保响应对象和方法的名称不匹配。同样的事情也适用于方法参数。
f87krz0w2#
您有两个XML模式元素,它们具有相同的名称(
createAccountResponse
)和相同的命名空间(http://kona.webservice.sif.unidata.com/
),分别对应于Java类型com.unidata.sif.kona.account.message.CreateAccountResponse
和com.unidata.sif.webservice.kona.jaxws.CreateAccountResponse
。由于第二个元素是由WebMethod注解“自动”生成的,因此更改消息元素的XMLType注解会更容易。要解决这个问题,您应该为其中一个更改
name
,或者定义两个独立的名称空间(一个用于消息元素,另一个用于WS请求和响应组件)。一、工程师:
**1.**更改消息元素的名称
com.unidata.sif.kona.account.message.CreateAccountResponse
。**2.**在消息元素处更改名称空间(包
com.unidata.sif.kona.account.message
)jaql4c8m3#
我得到了同样的错误,但我无法调整带有@XmlType注解(来自库)的类。因此,另一个解决方案是提供一个
com.unidata.sif.kona.account.message/package-info.java
,其中包含以下代码fiei3ece4#
另一个解决方案是使用
@WebMethod(operationName="differentFromMethodName")
,这甚至会改变客户端上的接口方法名。JAX-WS仍然使用SEI的方法名为wsgen和wsimport生成类;但现在消息元素类与JAX_WS内部生成的类不同。我不想触及wsgen生成的类(消息元素类)。