`

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 ...

    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...

    jaxb2.1jar包

    这个是jaxb2.1 jar包,这里提供下载,只要2个资源分哦,大家可以踊跃下载

    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 在webservice中常用的几个jar包,

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

    cxf框架与jdk6出现冲突的支持包,请大家支持下!

    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.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-...

    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-...

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

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

    jaxb-api-2.0.jar

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

    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; 包含翻译后的API文档:jaxb-api-2.3.1-javadoc-API文档-中文(简体)-英语-对照版.zip ...

    jaxb-api-2.1-sources.jar

    自己使用过,jaxb-api的jar包 亲测可用,请放心下载!

    jaxb-api.jar

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

    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-...

Global site tag (gtag.js) - Google Analytics