dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar}

Viewed 5000

i'm trying to compile a web service client generated out of Netbeans 11.2. The following pom.xml is being used:

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>sk_simo_examples</groupId>
    <artifactId>CalculatorWS_Client_Application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <resources>
            <resource>
                <targetPath>META-INF</targetPath>
                <directory>src</directory>
                <includes>
                    <include>jax-ws-catalog.xml</include>
                    <include>wsdl/**</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlFiles>
                                <wsdlFile>localhost_8080/CalculatorWSApplication/CalculatorWS.wsdl</wsdlFile>
                            </wsdlFiles>
                            <packageName></packageName>
                            <vmArgs>
                                <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                            </vmArgs>
                            <wsdlLocation>http://localhost:8080/CalculatorWSApplication/CalculatorWS?wsdl</wsdlLocation>
                            <staleFile>${project.build.directory}/jaxws/stale/CalculatorWS.stale</staleFile>
                        </configuration>
                        <id>wsimport-generate-CalculatorWS</id>
                        <phase>generate-sources</phase>
                    </execution>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlFiles>
                                <wsdlFile>localhost_8080/CalculatorWSApplication/CalculatorWS.wsdl</wsdlFile>
                            </wsdlFiles>
                            <packageName></packageName>
                            <vmArgs>
                                <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                            </vmArgs>
                            <wsdlLocation>http://localhost:8080/CalculatorWSApplication/CalculatorWS?wsdl</wsdlLocation>
                            <staleFile>${project.build.directory}/jaxws/stale/CalculatorWS_1.stale</staleFile>
                        </configuration>
                        <id>wsimport-generate-CalculatorWS_1</id>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>javax.xml</groupId>
                        <artifactId>webservices-api</artifactId>
                        <version>2.0</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                    <xnocompile>true</xnocompile>
                    <verbose>true</verbose>
                    <extension>true</extension>
                    <catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.metro</groupId>
            <artifactId>webservices-rt</artifactId>
            <version>2.3</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
</project>

The build fails with a main error:

[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (wsimport-generate-CalculatorWS) on project CalculatorWS_Client_Application: Mojo failed - check output -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (wsimport-generate-CalculatorWS) on project CalculatorWS_Client_Application: Mojo failed - check output 

However I suspect these lines being a reason for failed compilation:

[WARNING] Failed to build parent project for com.sun.xml.ws:jaxws-tools:pom:2.2.8
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} @ com.sun.xml.ws:jaxws-ri-bom:2.2.8, /home/miso/.m2/repository/com/sun/xml/ws/jaxws-ri-bom/2.2.8/jaxws-ri-bom-2.2.8.pom, line 395, column 29

When checked the pom file from local repository indeed contains the lines:

<!-- JDK dependencies -->
            <dependency>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
                <version>1.6</version>
                <scope>system</scope>
                <systemPath>${tools.jar}</systemPath>
            </dependency>

I'm not aware how to solve this, i'm a n00b when it comes to Java and Maven. Any ideas appreciated.

I have used to compile directly from command line. My environment:

Maven home: /opt/maven/apache-maven-3.6.3
Java version: 11.0.6, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-88-generic", arch: "amd64", family: "unix"

Chears, Michal

2 Answers

Thanks to khmarbaise I attempted to use a more recent version of jaxws-maven-plugin, version 2.6 and the build has been successful.

E.g. despite the Netbeans IDE generated these POM entries:

<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>

The solution was to use these instead:

<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.6</version>

Cheers, Michal

In my case, I was using hyperjaxb3 maven plugin version 0.6.1 in a java 11 project. The hyperjaxb3 plugin is using JAXB version 2.2.11 internally. In the pom file of JAXB 2.2.11, the tools.jar is used. tools.jar is removed from java 11 so that's why it is raising this warning. I tried to solve this problem by cloning the hyperjaxb3 maven plugin repository and modifying it to be compatible with java 11. here is the git repo https://github.com/Haylemicheal/hyperjaxb3 . Build it by yourself and use the snapshot version in your project.

Related