CXF与jdk冲突问题
在客户端与spring继承,测试时 cxf与java的包冲突
信息: 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.(ModelBuilder.java:173) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:456) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:302) 等等
在jdk目录的lib下(如C:\Program Files\Java\jdk1.5.0_17\jre\lib)建立文件夹endorsed将cxf对应jaxb-api-xx.jar和jaxb-impl-xx.jar拷贝到目录里,并在项目中不要导入这两个jar
j2ee5包冲突 信息:java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport at javax.activation.MailcapCommandMap.(MailcapCommandMap.java:140) at org.apache.cxf.attachment.AttachmentUtil.(AttachmentUtil.java:61) at org.apache.cxf.interceptor.AttachmentInInterceptor.handleMessage(AttachmentInInterceptor.java:61)
原因是项目中的java ee 5 libraries中的javaee.jar中activation/registries目录下没有LogSupport.jar所以要删除registries目录,方法用winrar打开eclipse目录下打开javaee.jar然后删除(如D:\Tools\Genuitec\Common\plugins\com.genuitec.eclipse.j2eedt.core_8.5.0.me201003231033\data\libraryset\EE_5目录下的javaeye.jar),然后下载新版包含LogSupport.jar的activation.jar包添加到项目中即可
如果把javaee.jar删除的话会报java.lang.NoClassDefFoundError: javax/activation/DataHandler 所以要保证java ee 5 libraries目录下有javaee.jar并且里面包含activation/DataHandler.jar
备忘一下。
我怎么照着你的做了之后还是有问题,只是没有报com/sun/activation/registries/LogSupport 这个错了,但出现了另一个错误,解释xml出错了.