Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap c

D:\apache-cxf-2.3.0\samples\java_first_pojo>ant server
Buildfile: D:\apache-cxf-2.3.0\samples\java_first_pojo\build.xml
    [mkdir] Created dir: D:\apache-cxf-2.3.0\samples\java_first_pojo\build
 [loadfile] Do not set property srcbuild.classpath as its length is 0.

maybe.generate.code:

compile:
    [mkdir] Created dir: D:\apache-cxf-2.3.0\samples\java_first_pojo\build\classes
    [mkdir] Created dir: D:\apache-cxf-2.3.0\samples\java_first_pojo\build\src
    [javac] D:\apache-cxf-2.3.0\samples\common_build.xml:118: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repe
atable builds
    [javac] Compiling 4 source files to D:\apache-cxf-2.3.0\samples\java_first_pojo\build\classes
 [loadfile] Do not set property srcbuild.classpath as its length is 0.

copy.maven.resources:

build:

server:
     [java] Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/D:/apache-cx
f-2.3.0/lib/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 t
he bootstrap classloader. (See
http://java.sun.com/j2se/1.6.0/docs/guide/standards/)
     [java]     at com.sun.xml.bind.v2.model.impl.ModelBuilder.<clinit>(ModelBuilder.java:173)
     [java]     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:456)
     [java]     at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
     [java]     at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
     [java]     at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
     [java]     at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
     [java]     at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
     [java]     at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
     [java]     at org.apache.cxf.jaxb.JAXBDataBinding.createContext(JAXBDataBinding.java:564)
     [java]     at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:504)
     [java]     at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
     [java]     at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
     [java]     at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:442)
     [java]     at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:505)
     [java]     at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:242)
     [java]     at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
     [java]     at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:148)
     [java]     at demo.hw.server.Server.<init>(Server.java:34)
     [java]     at demo.hw.server.Server.main(Server.java:38)
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 3 seconds

运行ant server(mvn -Pserver)时出现如上错误,从网上查找这个错误,解决办法如下:
在%java_home%\jre\lib\建立endorsed目录,并把cxf2.3中的jaxb-api-2.2.1.jar放进去就可以了。

你可能感兴趣的:(Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap c)