简体   繁体   中英

Apache CXF Dynamic Client creation

I am trying to use Apache CXF to talk to a unknown web service. I have followed the Dynamic Client example from Apache.

    JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
    Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);

This was working but now i am getting this exception when calling createClient():

    java.lang.IllegalStateException: Unable to create schema compiler
    Caused by:
     javax.xml.bind.JAXBException
     - with linked exception:
     [java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC]

This looks similar to an existing bug . I am using DOSGi singlebundle 1.2 which includes cxf-minimal-2.2.9.jar; meaning the bug should be fixed in the version I'm using. the jaxb-api is included in my Apache CXF distribution which upon inspection contains jaxb-xjc.

Can anybody provide me some insight as to what I'm doing wrong? I swear this used to work.

"java.lang.ClassNotFoundException: com/sun/tools/ " is often occurs if you use JRE in your IDE intead of JDK. Make sure, you use JDK in IDE (eg eclipse)

<dependency>
   <groupId>com.sun.xml.bind</groupId>
   <artifactId>jaxb-xjc</artifactId>
   <version>2.2.11</version>
</dependency>

resolved problem

另一种解决方案是在Maven依赖项中包含cxf-rt-core。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM