码迷,mamicode.com
首页 > 其他好文 > 详细

关于JAX-WS的Unable to create JAXBContext错误

时间:2016-06-06 18:37:00      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

参考: http://53873039oycg.iteye.com/blog/1979421

 

  今天学了下Jax-Ws的一个简单的例子,刚开始发布时遇到如下错误:

Java代码  
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  

    网上查了下资料,说是要指定

   

Java代码  

  原因:    

1 SOAPBinding的style默认为SOAPBinding.Style.DOCUMENT,要修改为RPC  
2 Jdk1.6版本低,换个高点的版本就可以了

    于是在接口上指定绑定的类型

  

Java代码  
@SOAPBinding(style = SOAPBinding.Style.RPC)  

 

    中午时候,想着以后每次都要写这么一行,麻烦,就把电脑上的jdk1.6.0.10换成了jdk1.6.0.32。

    下午试着返回List<User>类型,以前用过CXF,记得CXF的Jax-Ws返回List<JavaBean>这种类型是不需要配置的,结果刚发布就报错,错误信息如下:

    

Java代码  
  1. 技术分享
    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
    View Code

     遇到错误自己又不会于是谷歌了下,没找到我要的,又百度了下,网上说加上

    

Java代码  
  1. @SOAPBinding(style = SOAPBinding.Style.RPC)  
    @WebMethod 

    就OK了,RPC我有,就在实现类上加了@WebMethod,一发布还是报错,在又百度几次无果后,一次偶然的机会我把

   

Java代码  

  @SOAPBinding(style = SOAPBinding.Style.RPC) 

    这一行删了,再次发布,结果如下:

   

Java代码  
  1. 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错误

标签:

原文地址:http://www.cnblogs.com/liqun-12345/p/5564577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!