解决java.lang.ClassNotFoundException: org.codehaus.xfire.jaxb2.JaxbWSDLBuilderFactory

使用myeclipse生成的webservice客户端,在新建的java ee的web项目中执行没有任何问题,将代码放在现有的web工程的后,出现
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/xfire/jaxb2/JaxbWSDLBuilderFactory
    at org.codehaus.xfire.jaxws.JAXWSServiceFactory.(JAXWSServiceFactory.java:49)
    at org.codehaus.xfire.jaxws.JAXWSHelper.(JAXWSHelper.java:29)
    at org.codehaus.xfire.jaxws.JAXWSHelper.(JAXWSHelper.java:38)
    at org.codehaus.xfire.jaxws.ServiceDelegate.(ServiceDelegate.java:33)
    at org.codehaus.xfire.jaxws.ServiceDelegate.(ServiceDelegate.java:53)
    at org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32)
    at javax.xml.ws.Service.(Service.java:56)
    at com.digitalchina.app.trfvlt.chexingyi.register.ThirdPartyUserCarInforService.(ThirdPartyUserCarInforService.java:51)
    at com.digitalchina.app.trfvlt.chexingyi.test.Test.main(Test.java:21)
Caused by: java.lang.ClassNotFoundException: org.codehaus.xfire.jaxb2.JaxbWSDLBuilderFactory
    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)

    ... 9 more

怀疑是包冲突问题,但是使用myeclipse搜索,真的找不到这个类,估计是少了xfire-all-1.2.6.jar,加上去之后,出现新的异常
Exception in thread "main" java.lang.IllegalStateException: Could not initialize Service.
    at org.codehaus.xfire.jaxws.ServiceDelegate.(ServiceDelegate.java:77)
    at org.codehaus.xfire.jaxws.Provider.createServiceDelegate(Provider.java:32)
    at javax.xml.ws.Service.(Service.java:56)
    at com.digitalchina.app.trfvlt.chexingyi.register.ThirdPartyUserCarInforService.(ThirdPartyUserCarInforService.java:51)
    at com.digitalchina.app.trfvlt.chexingyi.test.Test.main(Test.java:21)
Caused by: java.lang.NoSuchMethodException: com.digitalchina.app.trfvlt.chexingyi.register.ThirdPartyUserCarInforService.getPortClassMap()
    at java.lang.Class.getMethod(Class.java:1605)
    at org.codehaus.xfire.jaxws.ServiceDelegate.(ServiceDelegate.java:60)
    ... 4 more

真的好奇怪,这次肯定是类冲突了,把项目之前lib的xfire-*全部删掉,竟然成功啦


你可能感兴趣的:(webservice)