NoSuchMethodError: com.sun.xml.ws.util.ServiceFinder.find

117 Views Asked by At

I am launching Maven command jaxws:wsdlgen, but it gives me this error

[INFO] jaxws:wsgen args: [-keep, -s, 'C:\Users\ActionICT-Motti\IdeaProjects\DocumentsStorage_v1\target\generated-sources\wsgen', -d, 'C:\Users\ActionICT-Motti\IdeaProjects\DocumentsStorage_v1\target\generated-sources\wsdl', -encoding, UTF-8, -wsdl, -r, 'C:\Users\ActionICT-Motti\IdeaProjects\DocumentsStorage_v1\target\generated-sources\wsdl', it.bper.ws.DocumentsStorageV1Impl, -Xnosource]
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at org.jvnet.jax_ws_commons.jaxws.Invoker.main(Invoker.java:72)
Caused by: java.lang.NoSuchMethodError: com.sun.xml.ws.util.ServiceFinder.find(Ljava/lang/Class;Ljava/util/ServiceLoader;)Lcom/sun/xml/ws/util/ServiceFinder;
    at com.sun.tools.ws.wscompile.WsgenOptions.<init>(WsgenOptions.java:106)
    at com.sun.tools.ws.wscompile.WsgenTool.<init>(WsgenTool.java:72)
    at com.sun.tools.ws.wscompile.WsgenTool.<init>(WsgenTool.java:82)

the pom is

<?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>xxxx</groupId>
    <artifactId>xxxx</artifactId>
    <packaging>war</packaging>
    <version>1.22.0-SNAPSHOT</version>
    <name>xxxx</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <filenet.cpe.install.path>X:/Program Files/IBM/FileNet/ContentEngine</filenet.cpe.install.path>
    </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.18.26</version>
            <scope>provided</scope>
        </dependency>

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


        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-standalone</artifactId>
            <version>3.0.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>C:/Users/ActionICT-Motti/IdeaProjects/DocumentsStorage_v1/src/main/webapp/WEB-INF/lib/Jace.jar
            </systemPath>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>rt</artifactId>
            <version>2.3.3</version>
        </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.21.1</version>
        </dependency>

        <!-- Test libraries -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.16.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.14.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1</version>
        </dependency>
      <!--  <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.1</version>
        </dependency>
        &lt;!&ndash; https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api-parent &ndash;&gt;
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api-parent</artifactId>
            <version>4.0.1</version>
            <type>pom</type>
        </dependency>-->

        <dependency>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <version>0.14.0</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.4.0-b180830.0359</version>
        </dependency>
        <dependency>
            <groupId>javax.jws</groupId>
            <artifactId>javax.jws-api</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>2.4.0-b180830.0438</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>javax.activation-api</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>javax.xml.soap</groupId>
            <artifactId>javax.xml.soap-api</artifactId>
            <version>1.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0.1</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>3.0.0</version>
        </dependency>

        <!--<dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-ri</artifactId>
            <version>2.3.3</version>
        </dependency>-->

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.2.1</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>[17,)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
            <!--<plugin>
                <groupId>com.sun.xml.ws</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>4.0.1</version>
                <executions>
                    <execution>
                        <id>1</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <xadditionalHeaders>true</xadditionalHeaders>
                            <executable>${tool.wsimport}</executable>&lt;!&ndash; Piu' veloce nel generare i sorgenti &ndash;&gt;
                            <wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
                            <target>3.0</target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>-->
            <plugin>
                <groupId>com.sun.xml.ws</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3.6</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>3.4.0</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.11</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.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>4.0.0.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>23.0.0.Final</version>
                    <javaOpts>
                        -Xms64m
                        <!--                        -Xmx512m-->
                        <!--                        -XX:MaxMetaspaceSize=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-->
                    </javaOpts>
                    <port>10090</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>
                    </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>
                <version>3.1.0</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>3.1.0</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.wildfly.plugins</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <version>4.2.0.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 change the version and the dependencies, but nothing works to resolve the problem.

EDIT: This is similar, but is not the same method that I've reported here. I don't understand why someone suggested it...

0

There are 0 best solutions below