Migrate jws from Java 7 to Java 11

34 Views Asked by At

My classes uses the following modules (list is from multiple classes):

import javax.jws.HandlerChain;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.bind.annotation.XmlRootElement;

This is the pom

<?xml version="1.0" encoding="UTF-8"?>
<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>******</groupId>
    <artifactId>*****</artifactId>
    <packaging>war</packaging>
    <version>1.22.1</version>
    <name>***** Maven Webapp</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <repositories>
        <!-- Repository per scaricare JBoss AS -->
        <repository>
            <id>jboss-enterprise-maven-repository</id>
            <name>JBoss Enterprise Maven Repository - Early-access repository</name>
            <url>https://maven.repository.redhat.com/earlyaccess/all</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.16</version>
            <scope>provided</scope>
        </dependency>

        <!-- Common libraries -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3.2</version>
        </dependency>

        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>2.4.1</version>
            <scope>test</scope>
        </dependency>

        <!--
             IBM Filenet libraries
             A runtime servono tutti i JAR, come da documentazione FileNet:
             - Jace.jar
             - stax-api.jar
             - xlxpScanner.jar
             - xlxpScannerUtils.jar
             - log4j.jar (la versione nel FileNet di BPER e' la 1.2.14)
             ma qui riportiamo solo quelli strettamente necessari per compilare
             ed eseguire i test, perche' gli altri JAR sono in WEB-INF/lib
             quindi accessibili dal class loader della web application
          -->
        <dependency>
            <groupId>com.ibm.filenet</groupId>
            <artifactId>jace</artifactId>
            <version>4.5.2</version>
            <scope>system</scope>
            <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/Jace.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>

        <!-- Logging libraries -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.12.4</version>
        </dependency>

        <!-- Test libraries -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.21.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <parallel>all</parallel>
                    <useUnlimitedThreads>false</useUnlimitedThreads>
                    <threadCount>6</threadCount>
                    <perCoreThreadCount>true</perCoreThreadCount>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.4.1</version>
                <executions>
                    <execution>
                        <id>enforce-java</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <message>Il JDK da utilizzare dev'essere 1.7</message>
                                    <version>[1.7,1.8)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3</version>
                <executions>
                <execution>
                    <id>1</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <xadditionalHeaders>true</xadditionalHeaders>
                        <executable>${tool.wsimport}</executable><!-- Piu' veloce nel generare i sorgenti -->
                        <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
                        <target>2.1</target>
                    </configuration>
                </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>external.atlassian.jgitflow</groupId>
                <artifactId>jgitflow-maven-plugin</artifactId>
                <version>1.0-m5.1</version>
                <configuration>
                    <releaseBranchVersionSuffix>RC</releaseBranchVersionSuffix>
                    <noDeploy>true</noDeploy>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.0</version>
                <executions>
                    <!-- test unitari-->
                    <execution>
                        <id>prepare agent</id>

                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <!-- test integrazione -->
                    <execution>
                        <id>prepare agent integration</id>

                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <propertyName>jacocoAgent</propertyName>
                            <classDumpDir>${project.build.directory}/dumpClassDir</classDumpDir>
                            <output>file</output>
                            <append>true</append>
                            <dumpOnExit>true</dumpOnExit>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.8.Final</version>
                <configuration>
                    <!--
                         In produzione c'e' JBoss EAP 6.3 => JBoss AS 7.4.0.Final
                         ma tale release non e' disponibile nei repo Maven
                         quindi usiamo la versione piu' simile disponibile
                      -->
                    <version>7.4.0.Final-redhat-4</version>
                    <jvmArgs>-Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true
                        -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000
                        -Dsun.rmi.dgc.server.gcInterval=3600000
                        -Djboss.socket.binding.port-offset=100
                        -Djboss.server.config.dir=${project.build.testOutputDirectory}/configuration
                        ${jacocoAgent}
<!--                        &lt;!&ndash;per eseguire il debug remoto rimuovere il commento dalla riga sottostante-->
<!--                            -Xrunjdwp:transport=dt_socket,address=33333,server=y,suspend=y-->
                    </jvmArgs>
                    <port>10099</port>
                </configuration>
                <executions>
                    <execution>
                        <id>start</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <startup-timeout>120</startup-timeout>
                        </configuration>
                    </execution>
                    <execution>
                        <id>avoid-console-logging</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>execute-commands</goal>
                        </goals>
                        <configuration>
                            <execute-commands>
                                <commands>
                                    <command>/subsystem=logging/root-logger=ROOT:root-logger-unassign-handler(name="CONSOLE")</command>
                                </commands>
                            </execute-commands>
                        </configuration>
                    </execution>
                    <execution>
                        <id>deploy</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>undeploy</goal><!-- Per eseguire "mvn verify" e non solo "mvn clean verify" -->
                            <goal>shutdown</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId><!-- Deve stare ***DOPO*** il maven-resources-plugin -->
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>loadProperties</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <exportAntProperties>true</exportAntProperties>
                            <target>
                                <exec executable="hostname" outputproperty="computer.hostname" />
                                <!-- Default "overwrite=false" => non sovrascrive l'eventuale properties gia' presente -->
                                <copy file="src/test/resources/local.properties" tofile="${project.build.outputDirectory}/${computer.hostname}.properties" />
                                <loadproperties srcFile="${project.build.outputDirectory}/${computer.hostname}.properties" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings
                    only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.jvnet.jax-ws-commons</groupId>
                                        <artifactId>jaxws-maven-plugin</artifactId>
                                        <versionRange>[2.3,)</versionRange>
                                        <goals>
                                            <goal>wsimport</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>

        <profile>
            <id>Jenkins</id>
            <build>
                <plugins>
                    <!--forza l'utilizzo della toolchain JDK 7 per la build -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-toolchains-plugin</artifactId>
                        <version>1.1</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>toolchain</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <toolchains>
                                <jdk>
                                    <version>1.7</version>
                                </jdk>
                            </toolchains>
                        </configuration>
                    </plugin>
                    <!--Il plugin di JBoss non è toolchain-aware, per cui si deve forzare l'esecuzione di JBoss su JDK7 -->
                    <plugin>
                        <groupId>org.jboss.as.plugins</groupId>
                        <artifactId>jboss-as-maven-plugin</artifactId>
                        <version>7.8.Final</version>
                        <configuration>
                            <javaHome>${jdkJenkins}</javaHome>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <jdkJenkins>/opt/java/jdk1.7.0_71</jdkJenkins>
                <!--disabilita il plugin enforcer (perche' non e' toolchain-aware e comunque non serve dal -->
                <!--momento che si specifica esplicitamente il JDK utilizzato tramite JDK toolchain        -->
                <enforcer.skip>true</enforcer.skip>
                <!-- imposta il path di wsimport nel server Jenkins per il maven-jaxws-plugin -->
                <tool.wsimport>${jdkJenkins}/bin/wsimport</tool.wsimport>
            </properties>
        </profile>
    </profiles>
</project>

I have tried:

  • to upgrade jaxws-maven-plugin to com.sun.xml.ws with newer version, adding dependencies following various answers here.
  • migrate to Jakarta, converting imports accordingly.

But every times it gives me different errors. I cannot find the right combinations of plugins and dependencies. Any help?

0

There are 0 best solutions below