com.sun .xml.bind.v2.contextfactory 类找不到的解决
用cxf+spring发布webservice,使用apache-cxf客户端方式调用接口访问服务器时,报javax.xml.bind.jaxbexception:
provider com.sun.xml.bind.v2.contextfactory not
found 错误,异常堆栈信息如下:
caused by: javax.xml.bind.jaxbexception: provider
com.sun.xml.bind.v2.contextfactory not found
- with linked exception:
[java.lang.classnotfoundexception:
com.sun.xml.bind.v2.contextfactory]
at javax.xml.bind.contextfinder.newinstance(contextfinder.java:151)
at javax.xml.bind.contextfinder.find(contextfinder.java:299)
at javax.xml.bind.jaxbcontext.newinstance(jaxbcontext.java:372)
at javax.xml.bind.jaxbcontext.newinstance(jaxbcontext.java:337)
at
org.apache.cxf.wsdl.jaxbextensionhelper.createjaxbcontext(jaxbextensionhelper.java:196)
org.apache.cxf.wsdl.jaxbextensionhelper.getjaxbcontext(jaxbextensionhelper.java:183)
... 65 more
caused by: java.lang.classnotfoundexception:
com.sun.xml.bind.v2.contextfactory
at java.net.urlclassloader$1.run(urlclassloader.java:202)
at java.security.accesscontroller.doprivileged(native method)
at java.net.urlclassloader.findclass(urlclassloader.java:190)
at java.lang.classloader.loadclass(classloader.java:306)
at sun.misc.launcher$appclassloader.loadclass(launcher.java:301)
at java.lang.classloader.loadclass(classloader.java:247)
at javax.xml.bind.contextfinder.newinstance(contextfinder.java:116)
... 70 more
,纠结了很久,各种办法都尝试了,最后才发现是jre顺序的问题,解决办法如下:
在启动类路径中, java ee 5 library 在 jre system library[jdk1.6.0_25]
之前, 调整顺序,将jre放在前面解决。
有问题的类路径顺序(eclipse:run->run
configrations...):
