Search code examples
javacxf

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.


Solution

  • "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 (e.g. eclipse)