Reputation: 31
I'm trying to update the Java version of a Java project (using intellij as IDE).
So, I installed JDK 17 and I found out that wsimport was removed. But is there any solution/alternative that is not deprecated so I can import and generate java classes?
I also found that I can still use wsimport (only if I set as java path Java 8) and run the code with maven jaxws-rt, but that packages in 2022 also look like they're already deprecated too, because I can only use 2.x version.
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.5</version>
</dependency>
there's already a "3.0.2" version, but if I update it i'll get a compilation error when I execute "mvn clean install": package javax.jws does not exist
and the runtime error when I try to consume the service: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61) ~[jaxws-api-2.3.1.jar:?]
the is my pom.xml file:
<properties>
<log4j.version>2.17.0</log4j.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>rm.ccr.JCCUI</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- Copy project dependency -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- exclude junit, we need runtime dependency only -->
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/lib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jgoodies/jgoodies-common -->
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>jgoodies-common</artifactId>
<version>1.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>javax.media</groupId>
<artifactId>jai_core</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.media</groupId>
<artifactId>jai_imageio</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>jgoodies-forms</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
So, these are in reality two questions:
1- How can I generate wsdl java classes only with jdk17 and non-deprecated libs.
2- How can I consume SOAP services in java without deprecated libs?
Upvotes: 2
Views: 6290
Reputation: 1
I used wsimport to generate the class files from WSDL. After that I used maven-replacer-plugin to replace javax.* references to jakarta.* (as previous answer) and update dependency reference to new JAX WS RI version.
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>4.0.3</version>
<type>pom</type>
</dependency>
Upvotes: 0
Reputation: 21
I was going through this same issue. So, I used cfx plugin to generate the class files from WSDL. After that I used maven-replacer-plugin to replace javax.xml.bind imports with jakarta.xml.bind.
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>replace-for-jakarta</id>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<filesToInclude>target/generated-sources/**/*.java</filesToInclude>
<preserveDir>true</preserveDir>
<replacements>
<replacement>
<token>javax.xml.bind</token>
<value>jakarta.xml.bind</value>
</replacement>
<replacement>
<token>javax.xml.ws</token>
<value>jakarta.xml.ws</value>
</replacement>
<replacement>
<token>javax.jws</token>
<value>jakarta.jws</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 1