Found the issue, I was using java11 to run my app instead of java8 ________________________________ From: masber masber Sent: Sunday, 26 April 2020 14:49 To: [email protected] <[email protected]> Subject: my first ws client attempt
Dear Apache CXF user community, I have to build a ws client from a wsdl file. I have adopted the instructions in here https://cxf.apache.org/docs/developing-a-consumer.html and this is what I have done: 1. Download wsdl file: curl -o Authenticate.wsdl https://uat.centiro.com/Universe.Services/TMSBasic/Wcf/c1/i1/TMSBasic/Authenticate.svc?wsdl 2. Change URL: sed "s|http://tempuri.org/|https://uat.centiro.com/Universe.Services/TMSBasic/Wcf/c1/i1/TMSBasic/Authenticate.svc/xml|g" Authenticate.wsdl > Authenticate_uat.wsdl 3. Create client stub: ~/Downloads/apache-cxf-3.3.6/bin/wsdl2java -client -d uat/ Authenticate_uat.wsdl 4. Import the maven project into eclipse and run the main method. This is the error I am getting: Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/ws/Service at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at com.centiro.facade.shared._1._0.servicecontract.ISharedOperations_BasicHttpBindingISharedOperations_Client.main(ISharedOperations_BasicHttpBindingISharedOperations_Client.java:36) Caused by: java.lang.ClassNotFoundException: javax.xml.ws.Service at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 10 more This is the main class public final class ISharedOperations_BasicHttpBindingISharedOperations_Client { private static final QName SERVICE_NAME = new QName("https://uat.centiro.com/Universe.Services/TMSBasic/Wcf/c1/i1/TMSBasic/Authenticate.svc/xml", "SharedOperations"); private ISharedOperations_BasicHttpBindingISharedOperations_Client() { } public static void main(String args[]) throws java.lang.Exception { URL wsdlURL = SharedOperations.WSDL_LOCATION; if (args.length > 0 && args[0] != null && !"".equals(args[0])) { File wsdlFile = new File(args[0]); try { if (wsdlFile.exists()) { wsdlURL = wsdlFile.toURI().toURL(); } else { wsdlURL = new URL(args[0]); } } catch (MalformedURLException e) { e.printStackTrace(); } } SharedOperations ss = new SharedOperations(wsdlURL, SERVICE_NAME); ISharedOperations port = ss.getBasicHttpBindingISharedOperations(); { System.out.println("Invoking authenticate..."); org.datacontract.schemas._2004._07.centiro_facade_common_operations.AuthenticateRequest _authenticate_authenticateRequest = null; org.datacontract.schemas._2004._07.centiro_facade_common_operations.AuthenticateResponse _authenticate__return = port.authenticate(_authenticate_authenticateRequest); System.out.println("authenticate.result=" + _authenticate__return); } System.exit(0); } } and this is my maven file: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>wstest</groupId> <artifactId>wstest</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>wstest</name> <dependencyManagement> <dependencies> <dependency> <groupId>org.glassfish.jersey</groupId> <artifactId>jersey-bom</artifactId> <version>${jersey.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>3.3.6</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> <version>3.3.6</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>3.3.6</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId> <version>3.3.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>2.10.3</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> <version>9.4.27.v20200227</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <inherited>true</inherited> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>com/centiro/facade/shared/_1/_0/servicecontract/ISharedOperations_BasicHttpBindingISharedOperations_Client.java</mainClass> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>prepare-package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory> ${project.build.directory}/libs </outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.2.0</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>libs/</classpathPrefix> <mainClass> com/centiro/facade/shared/_1/_0/servicecontract/ISharedOperations_BasicHttpBindingISharedOperations_Client.java </mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> <properties> <jersey.version>2.30</jersey.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project> My impression is that my project is trying to use the jdk ws classes instead fo the ounces provided by cxf. Does it look like my project is trying to use jax-ws classes provided by jdk8? What am I doing wrong? thank you very much
