com.sun:tools:jar的“ dependency.systemPath”必须指定绝对路径,但必须为$ {tools.jar}

时间:2020-03-01 19:21:44

标签: java maven

我正在尝试编译从Netbeans 11.2生成的Web服务客户端。 正在使用以下pom.xml:

<?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>

构建失败,并出现主要错误:

[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 

但是我怀疑这些行是编译失败的原因:

[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

选中后,本地存储库中的pom文件确实包含以下行:

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

我不知道如何解决这个问题,在Java和Maven方面我是n00b。任何想法表示赞赏。

我曾经直接从命令行进行编译。 我的环境:

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"

小白兔, 米哈尔

1 个答案:

答案 0 :(得分:0)

由于khmarbaise,我尝试使用2.6版的 jaxws-maven-plugin 的更新版本,并且构建成功。

例如尽管Netbeans IDE生成了以下POM条目:

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

解决方案是改用这些:

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

干杯, 米哈尔