关于JAX-WS的Unable to create JAXBContext错误
Posted 力群
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于JAX-WS的Unable to create JAXBContext错误相关的知识,希望对你有一定的参考价值。
参考: http://53873039oycg.iteye.com/blog/1979421
今天学了下Jax-Ws的一个简单的例子,刚开始发布时遇到如下错误:
com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.test.service.jaxws.add is not found. Have you run APT to generate them? SOAPBinding
网上查了下资料,说是要指定
原因:
1 SOAPBinding的style默认为SOAPBinding.Style.DOCUMENT,要修改为RPC
2 Jdk1.6版本低,换个高点的版本就可以了
于是在接口上指定绑定的类型
中午时候,想着以后每次都要写这么一行,麻烦,就把电脑上的jdk1.6.0.10换成了jdk1.6.0.32。
下午试着返回List<User>类型,以前用过CXF,记得CXF的Jax-Ws返回List<JavaBean>这种类型是不需要配置的,结果刚发布就报错,错误信息如下:
-
Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContext at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83) at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244) at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:312) at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:178) at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:456) at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:475) at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:213) at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:143) at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:102) at javax.xml.ws.Endpoint.publish(Endpoint.java:170) at com.huse.ws.basic.chap.server.test.MyServer.main(MyServer.java:13) Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions java.util.List is an interface, and JAXB can\'t handle interfaces. this problem is related to the following location: at java.util.List java.util.List does not have a no-arg default constructor. this problem is related to the following location: at java.util.List at java.security.AccessController.doPrivileged(Native Method) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:140) ... 11 more
遇到错误自己又不会于是谷歌了下,没找到我要的,又百度了下,网上说加上
-
@SOAPBinding(style = SOAPBinding.Style.RPC) @WebMethod
就OK了,RPC我有,就在实现类上加了@WebMethod,一发布还是报错,在又百度几次无果后,一次偶然的机会我把
@SOAPBinding(style = SOAPBinding.Style.RPC)
这一行删了,再次发布,结果如下:
-
2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.Plus 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.PlusResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.Minus 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.MinusResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.AddUser 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.AddUserResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.GetUser 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.GetUserResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.ListUser 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.ListUserResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.Login 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.LoginResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getExceptionBeanClass 信息: Dynamically creating exception bean Class com.huse.ws.basic.chap.server.inter.jaxws.UserExceptionBean
OK了。
再次说明,本次Jdk版本是jdk.1.6.0.32,Jdk1.6.0.10上面我没测试过。
以上是关于关于JAX-WS的Unable to create JAXBContext错误的主要内容,如果未能解决你的问题,请参考以下文章
关于“java.lang.OutOfMemoryError : unable to create new native Thread”的报错问题
解决OutOfMemoryError: unable to create new native thread
delphi 7 unable to create process
解决pip install package时Fatal error in launcher: Unable to create process using '"e:python36(
Unable to create new web application
Android Studio - Unable to create Debug Bridge: Unable to start adb server: adb server version (32)