这个问题估计老生常谈了。试着跟些一段简单的代码程序,很简单的那种哦~HelloWorld,用CXF实现
三个java文件《MainServer》、《HelloWorld》、《HelloWorldImpl》代码就不贴了,很简单的那种
但是在运行MainServer时报错了!
信息: Creating Service {http://test/}HelloWorldImplService from class test.HelloWorld Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/Java/apache-cxf-2.4.1/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 the bootstrap classloader. (See http://java.sun.com/j2se/1.6.0/docs/guide/standards/) 。。。 at test.MainServer.main(MainServer.java:17) |
我起初是以为程序的错误,后来排除该可能。
在网上把错误提示“Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI ”复制粘贴,谷歌一下(顺带提一句,查技术资料,谷歌很强大,比度娘强多了~),发现有好多的解决方案,而且大都类似
基本上就是由于jdk1.6与CXF的冲突之说,解决方案大同:
在jdK目录下的jre/lib/中建立endorsed文件夹,然后将 jaxb-api-2.2.1.jar包 与jaxb-impl-2.2.1.1.jar包 拷入endorsed文件夹中,并将%JDK_HOME%\jre\lib\endorsed加入classpath后解决 |
关键还是要找准包!我刚开始找得包很多但都不对,一定死2.2.1这样精确的找才行哦~
经过不停的股沟搜索,终于找到一个还算是不错的下载包的地方,特此分享:http://grepcode.com/ 进去搜搜就找得到了。
后来哎上述做得,解决成功!