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...):
