博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java使用JAX-WS来写webservice时 Unable to create JAXBContext
阅读量:5262 次
发布时间:2019-06-14

本文共 7066 字,大约阅读时间需要 23 分钟。

webservice,作为web开发人员来说必须掌握的一门技术,它的好处这里就不多说了,eclipse中自带了一种生成webservice的 方法,使用JAX-WS,如果我没有弄错的话,它需要javaEE5.0、JDK1.5以上,了解完这些就开始写接口方法。各种随心所欲。不料在用 eclipse生成webservice时出现错误了,生成不了,错误信息如下“ An internal error occurred during: "Generating JAX-WS Web Services". Unable to create JAXBContext ”  ,错误堆栈如下:

十一月 16, 2015 1:01:32 下午 org.apache.catalina.core.ApplicationContext log信息: Initializing Spring root WebApplicationContext十一月 16, 2015 1:01:35 下午 org.apache.catalina.core.StandardContext filterStart严重: Exception starting filter ssoFilterjavax.xml.ws.WebServiceException: Unable to create JAXBContext    at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:156)    at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:84)    at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:234)    at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:328)    at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:190)    at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:498)    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:246)    at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:170)    at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:118)    at javax.xml.ws.Endpoint.publish(Endpoint.java:240)    at com.pcitc.sso.client.SSOFilter.init(SSOFilter.java:42)    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)    at org.apache.catalina.core.ApplicationFilterConfig.
(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4038) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4692) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:701) at org.apache.catalina.startup.Catalina.start(Catalina.java:585) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptionsjavax.servlet.http.HttpServletRequest is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at javax.servlet.http.HttpServletRequest at public javax.servlet.http.HttpServletRequest com.pcitc.sso.client.webservice.jaxws.GetLoginUser.arg0 at com.pcitc.sso.client.webservice.jaxws.GetLoginUserjavax.servlet.http.HttpServletResponse is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at javax.servlet.http.HttpServletResponse at public javax.servlet.http.HttpServletResponse com.pcitc.sso.client.webservice.jaxws.GetLoginUser.arg1 at com.pcitc.sso.client.webservice.jaxws.GetLoginUser at java.security.AccessController.doPrivileged(Native Method) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:143) ... 37 moreCaused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptionsjavax.servlet.http.HttpServletRequest is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at javax.servlet.http.HttpServletRequest at public javax.servlet.http.HttpServletRequest com.pcitc.sso.client.webservice.jaxws.GetLoginUser.arg0 at com.pcitc.sso.client.webservice.jaxws.GetLoginUserjavax.servlet.http.HttpServletResponse is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at javax.servlet.http.HttpServletResponse at public javax.servlet.http.HttpServletResponse com.pcitc.sso.client.webservice.jaxws.GetLoginUser.arg1 at com.pcitc.sso.client.webservice.jaxws.GetLoginUser at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:442) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.
(JAXBContextImpl.java:274) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.
(JAXBContextImpl.java:125) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1127) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:173) at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:95) at com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:98) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:151) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:143) ... 39 more十一月 16, 2015 1:01:35 下午 org.apache.catalina.core.ApplicationContext log信息: Closing Spring root WebApplicationContext

真心让人郁闷,尤其是刚开始搞webservice的时候。其实仔细阅读一下堆栈信息就会发现,说 HttpServletRequest ,HttpServletResponse 是一个接口,而JAXB不能处理接口。记得网上有人说 JAX-WS只支持基本数据类型,int、String等,其实不是的,JAX支持的数据类型很多,List、HashMap、自定义对象等等都没问题, 只是不能处理接口,那就在方法的参数和返回值上不要有接口就好了。

转载于:https://www.cnblogs.com/longshiyVip/p/4968695.html

你可能感兴趣的文章
Linux查找命令对比(find、locate、whereis、which、type、grep)
查看>>
路由器外接硬盘做nas可行吗?
查看>>
python:从迭代器,到生成器,再到协程的示例代码
查看>>
Java多线程系列——原子类的实现(CAS算法)
查看>>
在Ubuntu下配置Apache多域名服务器
查看>>
多线程《三》进程与线程的区别
查看>>
linux sed命令
查看>>
html标签的嵌套规则
查看>>
[Source] Machine Learning Gathering/Surveys
查看>>
HTML <select> 标签
查看>>
类加载机制
查看>>
tju 1782. The jackpot
查看>>
湖南多校对抗赛(2015.03.28) H SG Value
查看>>
hdu1255扫描线计算覆盖两次面积
查看>>
hdu1565 用搜索代替枚举找可能状态或者轮廓线解(较优),参考poj2411
查看>>
bzoj3224 splay板子
查看>>
程序存储问题
查看>>
Mac版OBS设置详解
查看>>
优雅地书写回调——Promise
查看>>
android主流开源库
查看>>