`

WebServices CXF开发常见异常及解决方法

 
阅读更多
========== 异常1===

2011-7-14 9:55:15 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://services.ws.com/}IHelloServicesService from class com.ws.services.IHelloServices
Exception in thread "main" javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
at org.apache.cxf.helpers.XMLUtils.getDocumentBuilderFactory(XMLUtils.java:109)
at org.apache.cxf.helpers.XMLUtils.getParser(XMLUtils.java:133)
at org.apache.cxf.helpers.XMLUtils.parse(XMLUtils.java:151)
at org.apache.cxf.jaxb.JAXBDataBinding.<clinit>(JAXBDataBinding.java:111)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createDefaultDataBinding(ReflectionServiceFactoryBean.java:214)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.getDataBinding(AbstractServiceFactoryBean.java:109)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.getDataBinding(AbstractServiceFactoryBean.java:105)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.generatedWrapperBeanClass(JaxWsServiceFactoryBean.java:654)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.getExtraClass(JaxWsServiceFactoryBean.java:630)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:432)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:157)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
at com.test.ServerTest.<init>(ServerTest.java:19)
at com.test.ServerTest.main(ServerTest.java:23)


缺少xercesImpl.jar

======== =================异常2============== ====
2011-7-14 10:10:59 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://services.ws.com/}IHelloServicesService from class com.ws.services.IHelloServices
Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/E:/Project/workspace/CxfServices/libs/jaxb-impl-2.2.1.1.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.2 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (Seehttp://java.sun.com/j2se/1.6.0/docs/guide/standards/)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<clinit>(ModelBuilder.java:173)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:456)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at org.apache.cxf.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:258)
at org.apache.cxf.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:167)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:418)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:290)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:438)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:157)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
at com.test.ServerTest.<init>(ServerTest.java:19)
at com.test.ServerTest.main(ServerTest.java:23)

原因:jdk1.6.0_02中的jaxws-api-2.0.jar及jaxb-api-2.0.jar,而cxf需要jaxws-api-2.1.jar及jaxb-api-2.1.jar的支持。
解决方法:1、将cxf所需的2.1的jar复制一份到jdk目录下的jre\lib\endorsed文件夹中。如果endorsed文件不存在,可新建。
          2、jdk升级到1.6.0_22版本以上。


========= ===========异常3===== ====

2011-7-14 10:25:40 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://services.ws.com/}IHelloServicesService from class com.ws.services.IHelloServices
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Connector
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory.createJettyHTTPServerEngine(JettyHTTPServerEngineFactory.java:237)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.retrieveEngine(JettyHTTPDestination.java:113)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.finalizeConfig(JettyHTTPDestination.java:146)
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:278)
at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:134)
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:92)
at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:71)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:158)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
at com.test.ServerTest.<init>(ServerTest.java:19)
at com.test.ServerTest.main(ServerTest.java:23)

缺少jar包:jetty-server-7.4.2.v20110526.jar

======== ============异常4========== ===

2011-7-14 10:31:02 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://services.ws.com/}IHelloServicesService from class com.ws.services.IHelloServices
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/http/HttpBuffers
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.getHTTPConnectorFactory(JettyHTTPServerEngine.java:620)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.retrieveListenerFactory(JettyHTTPServerEngine.java:609)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.finalizeConfig(JettyHTTPServerEngine.java:659)
at org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory.createJettyHTTPServerEngine(JettyHTTPServerEngineFactory.java:239)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.retrieveEngine(JettyHTTPDestination.java:113)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.finalizeConfig(JettyHTTPDestination.java:146)
at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:278)
at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:134)
at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:92)
at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:71)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:158)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
at com.test.ServerTest.<init>(ServerTest.java:19)
at com.test.ServerTest.main(ServerTest.java:23)

缺少jetty-http-7.4.2.v20110526.jar


======================================================异常5=================================================================

Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.util.Map is an interface, and JAXB can't handle interfaces.
        this problem is related to the following location:
                at java.util.Map
                at private java.util.Map com.cecltd.service.jaxws_asm.SayHi.arg0
                at com.cecltd.service.jaxws_asm.SayHi
java.util.Map does not have a no-arg default constructor.         this problem is related to the following location:
                at java.util.Map
                at private java.util.Map com.cecltd.service.jaxws_asm.SayHi.arg0
                at com.cecltd.service.jaxws_asm.SayHi
解决方法:将服务端的services接口返回的Map类型的值,改成HashMap.
结论:在做webServices复杂类型值传递时,返回值的类型不要用接口类型。例如(List应该改为ArrayList,Map改为HashMap等)
分享到:
评论

相关推荐

    非常详细的cxf开发学习教程集合

    这包括WSDL(Web Services Description Language)的第一步,定义服务接口和数据类型,然后使用CXF工具生成服务实现和客户端代码。 4. **RESTful服务**:随着REST风格的流行,掌握如何用CXF构建RESTful API至关重要...

    实战Web Service —— 使用Apache CXF开发Web服务的教程

    【标题】:“实战Web Service —— 使用Apache CXF开发Web服务的教程” 【内容详解】: Web服务是一种基于开放标准的、平台无关的接口技术,它允许不同系统间的应用程序进行交互。Apache CXF是一个开源的Java框架,...

    JAVA访问WebServices接口的简单实例,android可用

    在Java编程语言中,访问Web Services接口是一项常见的任务,特别是在构建Android应用时,因为Web Services提供了数据交换和远程调用功能。本实例将探讨如何在Java中实现这一过程,特别适用于Android开发。以下是一个...

    cxf开发map的demo

    【标题】"cxf开发map的demo"是一个关于使用Java CXF框架处理Map类型数据的实战示例。CXF是一个开源服务框架,它允许开发者创建和消费Web服务,支持多种协议和绑定,包括SOAP、RESTful等。在这个demo中,我们将深入...

    java调用exchange web services

    Java调用Exchange Web Services(EWS)是一种常见的技术实践,用于与Microsoft Exchange Server进行交互,进行邮件发送、日历管理、联系人同步等任务。EWS是Exchange Server提供的一组基于SOAP协议的Web服务接口,...

    CXF

    CXF的JAX-RS(Java API for RESTful Web Services)实现使得REST服务的开发变得简单直观。 **文件“webit”** 虽然没有具体说明,但“webit”可能是指项目中的一个目录或子模块,通常与Web应用程序有关。在CXF项目...

    client cxf

    CXF(CXF: Composite eXtensible Services Framework)是一个开源的Java框架,它主要用于构建和服务消费Web服务。CXF客户端是该框架的一部分,用于与由CXF服务器端点提供的服务进行交互。在这个主题中,我们将深入...

    CXF3.1.13jar包

    4. **WS-*协议支持**:CXF支持一系列WS-*协议,如WS-Security、WS-Addressing和WS-Policy,这些都是在企业级Web服务中常见的安全和交互规范。 5. **客户端API**:CXF提供了一个强大的客户端API,允许开发者方便地...

    CXF3.0+Spring3.2 传输文件

    CXF通过JAX-WS(Java API for XML Web Services)和JAX-RS(Java API for RESTful Web Services)规范来支持文件传输。 接着,Spring3.2.14在其中的角色主要是作为服务管理和依赖注入框架。它可以帮助我们轻松地...

    cxf+spring实现webservice

    在IT行业中,开发Web服务是常见的需求,而CXF和Spring框架的结合为开发者提供了一种高效、灵活的方式来实现Web Service。本篇将深入探讨如何利用CXF和Spring来创建、部署和消费Web Service。 CXF,全称CXF Commons ...

    java使用xfire创建和调用webservices

    XFire 是 Apache CXF 的前身,它提供了一种轻量级的解决方案来创建和使用 WebServices。以下是一些关键特性: 1. **SOAP 支持**:XFire 支持 SOAP 1.1 和 1.2,允许开发者构建符合 SOAP 规范的 WebServices。 2. **...

    Java webservice cxf客户端调用demo和服务端

    Java WebService CXF客户端调用和服务端的实现是企业级应用程序中常见的通信方式,它基于标准的SOAP(Simple Object Access Protocol)协议,提供了一种在分布式环境中交换信息的方法。CXF是一个开源框架,它简化了...

    apache-CXF框架

    Apache CXF是一个开源的Java框架,专门用于构建和开发Web服务。它允许开发者创建符合WS-*标准的服务,同时也支持RESTful服务。CXF这个名字来源于两个早期的开源项目:XFire和Celtix,它们在2006年合并形成了现在的...

    利用cxf和spring发布SOAP服务 整合所需jar包.

    Apache CXF是一个开源的Java框架,它允许开发者创建和消费各种Web Services,包括SOAP和RESTful服务。CXF与Spring的集成使得在Spring应用中配置和管理CXF服务变得非常方便。 首先,我们需要理解SOAP服务的基本结构...

    webservices调用所需的包

    2. ** Axis2** 或 **Apache CXF**:这两个是流行的Java Web服务框架,它们提供了基于JAXRPC和SAAJ的实现,并且支持WSDL-first或Java-first的开发模式,简化了Web服务的创建和调用。 3. **SOAP消息结构**:理解SOAP...

    CXF webservice初学笔记

    7. `geronimo-jaxws_2.2_spec-1.0.jar`:Geronimo对Java API for RESTful Web Services (JAX-WS) 2.2规范的实现,JAX-WS是CXF处理SOAP Web服务的核心。 8. `geronimo-activation_1.1_spec-1.1.jar`:对JavaBeans ...

    spring+cxf编写简单的webservice接口

    这是一个常见的做法,因为Spring提供了强大的依赖注入和管理功能,而CXF则是一个用于构建和消费Web服务的开源框架。 在Spring中,我们可以使用Spring的注解驱动开发来配置和管理服务。首先,我们需要引入CXF的依赖...

    JSP动态网站开发

    理解如何使用JAX-WS(Java API for XML Web Services)或Apache CXF等框架实现Web Services是现代Web开发的重要技能。 综上所述,JSP动态网站开发涵盖了广泛的技能和知识,包括Servlet与会话管理、分层开发、JSTL和...

Global site tag (gtag.js) - Google Analytics