The JAXB 2.1 API is being loaded from the bootstrap ... (CXF with Java package conflicts)

Source: Internet
Author: User
Tags jboss

I'm learning cxf. When developing WebService in Web engineering, a package conflict occurs with the following error code:
Info: 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 to the bootstrap ClassLoader, but this R I (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. (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: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)

The solution is as follows:
Create the endorsed folder in the jre/lib/in the JDK directory, and then copy the Jaxb-api-2.2.1.jar and Jaxb-impl-2.2.1.1.jar packages into the endorsed folder, and%jdk_home%\jre\ Lib\endorsed joins Classpath to solve
Attached Original English
solve the problems of JAXB2.1 and jdk1.6/6.0 Programme 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 if you try to run applications this 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 are 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 to the JVM, you can check the current location by DoingSystem.out.println (System.getproperty ("Java.endorsed.dirs "));

Obviously you still need, jax-ws jars in your classpath.

Please don't put all of the jars to the endorsed directory. This is the makes it impossible for Jax-ws RI to and I classes that it needs for its operation, such as servlet classes on th e server-side, or Ant classes in the tool time. As those are not loaded by the bootstrap ClassLoader, and you'll get Noclassdeferror on servlet/ant.

Programme 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). Jars to take precedent on the JDK supplied jars, we have to use the endorsed directory Mechani SM, as described here. The above link is for using Jaxws RI 2.1, but we need JBOSSWS. For this purpose copy the following 3 jars in to the jboss/lib/endorsed directory.

So assuming your jboss are setup in a Directory/jboss and your 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 are already configured to add the/jboss/lib/endoresed directory to the list of endorsed dire Ctory. So jars in this directory would take precedence over Rt.jar.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.