Creating an Apache CXF Dynamic Client

I am trying to use Apache CXF to communicate with an unknown web service. I executed the Dynamic Client from Apache.

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

This worked, but now I get 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 seems like an existing error . I am using DOSGi singlebundle 1.2, which includes cxf-minimum-2.2.9.jar; this means that the error should be fixed in the version that I am using. jaxb-api is included in my Apache CXF distribution, which contains jaxb-xjc during verification.

Can someone give me some idea of ​​what I am doing wrong? I swear it worked.

+4
source share
3 answers

"java.lang.ClassNotFoundException: com / sun / tools /" often occurs if you use the JRE in your IDD instead of the JDK. Make sure you use the JDK in the IDE (e.g. eclipse)

+5
source

Another solution is to include the cxf-rt kernel in your Maven dependencies.

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

resolved problem

0
source

Source: https://habr.com/ru/post/1441662/


All Articles