`

JAXB 2.1 API is being loaded from the bootstrap……(cxf与java的包冲突)

    博客分类:
  • JAXB
阅读更多

今天在学cxf在web工程中开发webservice时,出现包冲突,其错误代码如下:
信息: Creating Service {http://service.css.ty.com/}MyFirstServiceHelloWorld from class com.ty.css.service.HelloWorldService
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:/javaLib/cxf_all_jar/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. (See http://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:585)
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.JAXBDataBinding.createContext(JAXBDataBinding.java:564)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:504)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:442)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:645)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:505)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:242)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:184)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:148)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:183)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:407)

解决办法如下:
在jdK目录下的jre/lib/中建立endorsed文件夹,然后将jaxb-api-2.2.1.jar包与jaxb-impl-2.2.1.1.jar包拷入endorsed文件夹中,并将%JDK_HOME%\jre\lib\endorsed加入classpath后解决
附上原版英文

解决JAXB2.1和JDK1.6/6.0的问题

方案1:

1.8. Using JAX-WS 2.1 with JavaSE6

JavaSE6 ships with JAX-WS 2.0 API in rt.jar, which causes some trouble when you try to run applications that use JAX-WS 2.1 API. This document collects information about how to solve this issue. 1.8.1. Endorsed directory

One way to fix this is to copy jaxws-api.jar and jaxb-api.jar into JRE endorsed directory, which is $JAVA_HOME/lib/endorsed (or $JDK_HOME/jre/lib/endorsed)

Some application containers, such as Glassfish, modifies the location of the endorsed directory to a different place. From inside the JVM, you can check the current location by doing System.out.println(System.getProperty("java.endorsed.dirs"));

Obviously you still need other JAX-WS jars in your classpath.

Please do not put all the jars to the endorsed directory. This makes it impossible for JAX-WS RI to see other classes that it needs for its operation, such as servlet classes on the server-side, or Ant classes in the tool time. As those are not loaded by the bootstrap classloader, you'll get NoClassDefError on servlet/Ant classes.

方案2:

Support for JDK 1.6

Jbossws 2.0.1.GA is based on the jax-ws and jaxb versions 2.1. But JDK 1.6 ships jaxb 2.0 classes as part of the core distribution (rt.jar). So in order for the jboss jars to take precedent over the jdk supplied jars, we have to use the endorsed directory mechanism, as described here. The above link is for using jaxws ri 2.1, but we need jbossws 2.0.1. For that purpose copy the following 3 jars in to the jboss/lib/endorsed directory.

So assuming your jboss is setup in a directory /jboss and you have already installed jbossws 2.0.1 on top of it, Copy the following 3 files to /jboss/lib/endorsed.

  • /jboss/server/default/lib/jboss-saaj.jar
  • /jboss/server/default/lib/jboss-jaxws.jar
  • /jboss/client/jaxb-api.jar

The jboss run script is already configured to add the /jboss/lib/endoresed directory to the list of endorsed directory. So jars in this directory will take precedence over rt.jar.

分享到:
评论

相关推荐

    jaxb-api-2.1.jar

    在使用webservice,esb等需要jaxb的项目里经常会出现 JAXB 2.0 API is being loaded from the bootstrap classloader错误.执行System.out.println(System.getProperty("java.endorsed.dirs"));输出jaxb-api-2.1.jar...

    jaxb-api-2.2 jaxb-impl

    在使用webservice,mule esb等需要jaxb的项目里经常会出现 JAXB 2.0 API is being loaded from the bootstrap classloader这个错误,按照打出的信息Use the endorsed directory mechanism to place jaxb-api.jar in ...

    jaxb2.1jar包

    5. **XPath支持**:通过使用XPath,JAXB2.1允许开发者更精确地指定XML数据与Java对象之间的映射关系。 6. **性能优化**:JAXB2.1在性能方面进行了优化,提升了XML文档的解析速度和内存使用效率。 **二、JAXB API**...

    jaxb-2_1_9.zip

    java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file://build/web/WEB-INF/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class...

    jaxws-api-2.1_jaxb-api-2.1.jar

    总结来说,`jaxws-api-2.1.jar`、`jaxb-api-2.1.jar`和`geronimo-jaxws_2.2_spec-1.1.jar`是Java Web服务开发中的关键组件,它们分别代表了JAX-WS 2.1 API、JAXB 2.1 API以及Geronimo对JAX-WS 2.2规范的实现。...

    jaxb-api-2.1.jar 和 jaxb-impl-2.1.8.jar

    总的来说,`jaxb-api-2.1.jar` 和 `jaxb-impl-2.1.8.jar` 在Java开发中扮演着重要的角色,它们为XML数据处理提供了强大的工具,使得XML与Java对象之间的转换变得简单易行。然而,随着技术的发展,开发者也应关注新的...

    jaxb-api.jar.jaxws-api.zip_ jaxb-api.jar_cxf_jax-ws.jar_jaxb-api

    **冲突解决** 当使用CXF框架并遇到与JDK 6内置JAXB库的冲突时,可以通过引入外部的`jaxb-api.jar`和`jaxws-api.jar`来解决。这两个jar文件提供了与CXF兼容的JAXB和JAX-WS实现,避免了与系统默认库的冲突。 **...

    jaxb-api-2.3.1-API文档-中文版.zip

    赠送jar包:jaxb-api-2.3.1.jar; 赠送原API文档:jaxb-api-2.3.1-javadoc.jar; 赠送源代码:jaxb-api-2.3.1-sources.jar; 赠送Maven依赖信息文件:jaxb-api-2.3.1.pom; 包含翻译后的API文档:jaxb-api-2.3.1-...

    CXF-JAXB包的处理问题

    本文将深入探讨如何解决CXF与JAXB版本冲突,以及如何处理Java.lang.LinkageError,特别是当JAXB 2.1 API与2.2 API之间发生不兼容时的情况。 首先,LinkageError通常发生在类加载过程中,当试图访问的类在不同的类...

    jaxb-api jaxb-impl jar

    同时,从Java 9开始,JAXB作为模块被包含在JDK中,因此对于这些新版本的Java,可能需要调整依赖管理策略,避免与JDK内置的JAXB冲突。 总之,JAXB是Java开发者处理XML数据的强大工具,而`jaxb-api.jar`和`jaxb-impl....

    jaxb-api-2.3.0-API文档-中文版.zip

    标签:javax、xml、bind、jaxb、api、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译...

    jaxb-api-2.3.0-API文档-中英对照版.zip

    标签:javax、xml、bind、jaxb、api、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准...

    jaxb-api-2.2.11-API文档-中英对照版.zip

    标签:javax、xml、bind、jaxb、api、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准...

    jaxb-api-2.2.11-API文档-中文版.zip

    标签:javax、xml、bind、jaxb、api、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译...

    jaxb-api-2.2.2-API文档-中文版.zip

    赠送jar包:jaxb-api-2.2.2.jar; 赠送原API文档:jaxb-api-2.2.2-javadoc.jar; 赠送源代码:jaxb-api-2.2.2-sources.jar; 赠送Maven依赖信息文件:jaxb-api-2.2.2.pom; 包含翻译后的API文档:jaxb-api-2.2.2-...

    javax.rar(jaxb-impl-2.3.0、jaxb-core-2.3.0、jaxb-api-2.3.0)

    在Java开发环境中,`javax.rar`这一提及实际上与RAR压缩库无关,而是涉及到Java的XML绑定(JAXB)技术。标题中的"jaxb-impl-2.3.0、jaxb-core-2.3.0、jaxb-api-2.3.0"是JAXB的不同组件版本号,它们在处理XML到Java...

    jaxb-api.jar

    jaxb-api 内部含有jaxb的api,对java.xml.bind 进行了封装

    jaxb-api-2.0.jar

    jaxb-api-2.0.jar jaxb-api-2.0.jar

Global site tag (gtag.js) - Google Analytics