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

weylhg0b  于 2023-03-06  发布在  Java
关注(0)|答案(3)|浏览(278)

我正在尝试编译从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>

我不知道如何解决这个问题,我是一个n00b当谈到Java和Maven。任何想法赞赏。
我习惯直接从命令行编译。我的环境:

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"

夏尔

kgsdhlau

kgsdhlau1#

多亏了khmarbaise,我尝试使用一个更新版本的 jaxws-maven-plugin,2.6版,构建已经成功。
例如,尽管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>

干杯米夏尔

ippsafx7

ippsafx72#

在我的例子中,我在java 11项目中使用了hyperjaxb3 maven插件版本0.6.1,hyperjaxb3插件内部使用的是JAXB版本2.2.11,在JAXB 2.2.11的pom文件中,tools.jar已被使用。tools.jar已从java 11中删除,因此它引发此警告。我试图通过克隆hyperjaxb3 maven插件库并修改它以兼容java 11来解决这个问题。这里是git repo https://github.com/Haylemicheal/hyperjaxb3。自己构建它并在项目中使用快照版本。

b4lqfgs4

b4lqfgs43#

在我的例子中,JAVA_HOME被设置为JRE,而不是Linux上的JDK

相关问题