maven jaxws执行wsgen失败

发布于 2024-12-25 11:38:07 字数 2138 浏览 4 评论 0原文

我将 netbeans 与 maven 3 一起使用。当我尝试使用 jaxws-maven-plugin 进行编译时,出现以下错误。

这是我的 pom

 <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>teamWS</id>
                    <goals>
                        <goal>wsgen</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                        <resourceDestDir>${project.build.directory}/classes/wsdl</resourceDestDir>
                        <sei>xyz.timerserver.server.TimeServer</sei>
                        <genWsdl>true</genWsdl>
                        <keep>true</keep>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>jsr250-api</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.jws</groupId>
        <artifactId>jsr181-api</artifactId>
        <version>1.0-MR1</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
    </dependency>

</dependencies>

这是我收到的错误消息。我尝试使用系统范围依赖项添加tools.jar,但仍然没有成功

Failed to execute goal org.codehaus.mojo:jaxws-maven-plugin:1.10:wsgen (teamWS) on project JWSServer: Failed to execute wsgen: com/sun/mirror/apt/AnnotationProcessorFactory: com.sun.mirror.apt.AnnotationProcessorFactory -> [Help 1]

I am using netbeans with maven 3. When I try to compile with jaxws-maven-plugin, I get the following error.

Here is my pom

 <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>teamWS</id>
                    <goals>
                        <goal>wsgen</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                        <resourceDestDir>${project.build.directory}/classes/wsdl</resourceDestDir>
                        <sei>xyz.timerserver.server.TimeServer</sei>
                        <genWsdl>true</genWsdl>
                        <keep>true</keep>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>jsr250-api</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.jws</groupId>
        <artifactId>jsr181-api</artifactId>
        <version>1.0-MR1</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
    </dependency>

</dependencies>

This is the error message that I get. I tried to add tools.jar using system scope dependency but still no luck

Failed to execute goal org.codehaus.mojo:jaxws-maven-plugin:1.10:wsgen (teamWS) on project JWSServer: Failed to execute wsgen: com/sun/mirror/apt/AnnotationProcessorFactory: com.sun.mirror.apt.AnnotationProcessorFactory -> [Help 1]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风铃鹿 2025-01-01 11:38:07

第一步,确保您使用正确的 java 版本运行 Maven - 在这种情况下,jaxws:wsgen (1.12) 似乎在 java 7 上出现故障使用java 6,即:

  • 如果您从 shell 运行它,export JAVA_HOME=/path/to/java/6
  • 如果您从 IDE 运行它,请指定java 版本位于IDE启动时间
    • 例如对于eclipse,使用启动选项-vm /path/to/java/6

对我来说,这解决了无法执行wsgencom.sun.xml.bind.v2.runtime.IllegalAnnotationsException 引起。

As a first step, ensure that you're running maven with a correct java version -- jaxws:wsgen (1.12) appears to malfunction with java 7, in such a case use java 6, i.e.:

  • if you run it from a shell, export JAVA_HOME=/path/to/java/6
  • if you're running it from an IDE, specify java version at the IDE start-up time
    • e.g. for eclipse, use start-up option -vm /path/to/java/6

For me, this solved the Failed to execute wsgen caused by com.sun.xml.bind.v2.runtime.IllegalAnnotationsException.

咆哮 2025-01-01 11:38:07

尝试使用 JAX-WS commons 项目中插件的更新版本。

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

Try using updated version of the plugin from JAX-WS commons project.

<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
公布 2025-01-01 11:38:07

该项目刚刚返回 MojoHaus,因此您应该使用那里的最新版本。

  1. <2007:1.0-1.12(groupId org.codehaus.mojo)
  2. 2007-2015:2.1-2.3.1(groupId org.codehaus.mojo) >org.jvnet.jax-ws-commons)
  3. 2015 年至今:>=2.4 (groupId org.codehaus.mojo

原始代码是在 Codehaus Mojo 项目中开发的,然后从 2007 年 3 月开始,该项目转移到 jax-ws-commons,版本 1.x 在 org.codehaus.mojo groupId 中,版本 2.x 在 org.jvnet 中.jax-ws-commons groupId。 2015年9月,2.4版本,又回到了org.codehaus.mojo groupId中的MojoHaus(Codehaus Mojo的新家)

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

The project just went back to MojoHaus so you should use the latest version from there.

  1. <2007: 1.0-1.12 (groupId org.codehaus.mojo)
  2. 2007-2015: 2.1-2.3.1 (groupId org.jvnet.jax-ws-commons)
  3. 2015-today: >=2.4 (groupId org.codehaus.mojo)

The original code was developed in the Codehaus Mojo project, then as of March 2007, the project moved to jax-ws-commons with version 1.x in org.codehaus.mojo groupId and version 2.x in org.jvnet.jax-ws-commons groupId. In September 2015, for version 2.4, it went back to MojoHaus (the new home of Codehaus Mojo) in org.codehaus.mojo groupId

<dependency>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>jaxws-maven-plugin</artifactId>
 <version>2.5</version>
</dependency>
陈年往事 2025-01-01 11:38:07

您可以使用官方示例配置,它可用 这里

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
    <executions>
        <execution>
            <id>compile</id>
            <goals>
                <goal>compile</goal>
            </goals>
            <phase>initialize</phase>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>@project.groupId@</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>@project.version@</version>
    <executions>
        <execution>
            <goals>
                <goal>wsgen</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <sei>org.codehaus.mojo.jaxws.it.HelloWorldImpl</sei>
                <genWsdl>true</genWsdl> <!-- for demo purpose only, the wepapp does not need those the generated wsdl files-->
                <keep>true</keep>
            </configuration>
        </execution>
    </executions>
</plugin>

请检查他们使用的依赖项以避免编译错误。查看 mvn dependency:tree 输出:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------< org.jvnet.jax-ws-commons:mojo.it.helloworldws >------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mojo.it.helloworldws ---
[INFO] org.jvnet.jax-ws-commons:mojo.it.helloworldws:war:1.0-SNAPSHOT
[INFO] \- com.sun.xml.ws:jaxws-rt:jar:2.3.2:compile
[INFO]    +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO]    +- jakarta.xml.ws:jakarta.xml.ws-api:jar:2.3.2:compile
[INFO]    +- jakarta.xml.soap:jakarta.xml.soap-api:jar:1.4.1:compile
[INFO]    +- jakarta.annotation:jakarta.annotation-api:jar:1.3.4:compile
[INFO]    +- jakarta.jws:jakarta.jws-api:jar:1.1.1:compile
[INFO]    +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.2:compile
[INFO]    |  +- org.glassfish.jaxb:txw2:jar:2.3.2:compile
[INFO]    |  \- com.sun.istack:istack-commons-runtime:jar:3.0.8:compile
[INFO]    +- com.sun.xml.ws:policy:jar:2.7.6:compile
[INFO]    +- org.glassfish.gmbal:gmbal:jar:4.0.0:compile
[INFO]    |  +- org.glassfish.external:management-api:jar:3.2.1:compile
[INFO]    |  +- org.glassfish.pfl:pfl-basic:jar:4.0.1:compile
[INFO]    |  +- org.glassfish.pfl:pfl-tf:jar:4.0.1:compile
[INFO]    |  |  +- org.glassfish.pfl:pfl-asm:jar:4.0.1:compile
[INFO]    |  |  \- org.glassfish.pfl:pfl-dynamic:jar:4.0.1:compile
[INFO]    |  +- org.glassfish.pfl:pfl-basic-tools:jar:4.0.1:compile
[INFO]    |  \- org.glassfish.pfl:pfl-tf-tools:jar:4.0.1:compile
[INFO]    +- org.jvnet.staxex:stax-ex:jar:1.8.1:compile
[INFO]    +- com.sun.xml.stream.buffer:streambuffer:jar:1.5.7:compile
[INFO]    +- org.jvnet.mimepull:mimepull:jar:1.9.11:compile
[INFO]    +- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.16:compile
[INFO]    +- org.glassfish.ha:ha-api:jar:3.1.12:compile
[INFO]    +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.5.1:compile
[INFO]    +- com.fasterxml.woodstox:woodstox-core:jar:5.1.0:runtime
[INFO]    +- org.codehaus.woodstox:stax2-api:jar:4.1:runtime
[INFO]    \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.808 s
[INFO] Finished at: 2022-10-15T12:58:08-03:00
[INFO] ------------------------------------------------------------------------

You can use the official example configuration, it is available here.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
    <executions>
        <execution>
            <id>compile</id>
            <goals>
                <goal>compile</goal>
            </goals>
            <phase>initialize</phase>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>@project.groupId@</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>@project.version@</version>
    <executions>
        <execution>
            <goals>
                <goal>wsgen</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <sei>org.codehaus.mojo.jaxws.it.HelloWorldImpl</sei>
                <genWsdl>true</genWsdl> <!-- for demo purpose only, the wepapp does not need those the generated wsdl files-->
                <keep>true</keep>
            </configuration>
        </execution>
    </executions>
</plugin>

Please review the dependencies they are using to avoid compilation errors. See the mvn dependency:tree output:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------< org.jvnet.jax-ws-commons:mojo.it.helloworldws >------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mojo.it.helloworldws ---
[INFO] org.jvnet.jax-ws-commons:mojo.it.helloworldws:war:1.0-SNAPSHOT
[INFO] \- com.sun.xml.ws:jaxws-rt:jar:2.3.2:compile
[INFO]    +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO]    +- jakarta.xml.ws:jakarta.xml.ws-api:jar:2.3.2:compile
[INFO]    +- jakarta.xml.soap:jakarta.xml.soap-api:jar:1.4.1:compile
[INFO]    +- jakarta.annotation:jakarta.annotation-api:jar:1.3.4:compile
[INFO]    +- jakarta.jws:jakarta.jws-api:jar:1.1.1:compile
[INFO]    +- org.glassfish.jaxb:jaxb-runtime:jar:2.3.2:compile
[INFO]    |  +- org.glassfish.jaxb:txw2:jar:2.3.2:compile
[INFO]    |  \- com.sun.istack:istack-commons-runtime:jar:3.0.8:compile
[INFO]    +- com.sun.xml.ws:policy:jar:2.7.6:compile
[INFO]    +- org.glassfish.gmbal:gmbal:jar:4.0.0:compile
[INFO]    |  +- org.glassfish.external:management-api:jar:3.2.1:compile
[INFO]    |  +- org.glassfish.pfl:pfl-basic:jar:4.0.1:compile
[INFO]    |  +- org.glassfish.pfl:pfl-tf:jar:4.0.1:compile
[INFO]    |  |  +- org.glassfish.pfl:pfl-asm:jar:4.0.1:compile
[INFO]    |  |  \- org.glassfish.pfl:pfl-dynamic:jar:4.0.1:compile
[INFO]    |  +- org.glassfish.pfl:pfl-basic-tools:jar:4.0.1:compile
[INFO]    |  \- org.glassfish.pfl:pfl-tf-tools:jar:4.0.1:compile
[INFO]    +- org.jvnet.staxex:stax-ex:jar:1.8.1:compile
[INFO]    +- com.sun.xml.stream.buffer:streambuffer:jar:1.5.7:compile
[INFO]    +- org.jvnet.mimepull:mimepull:jar:1.9.11:compile
[INFO]    +- com.sun.xml.fastinfoset:FastInfoset:jar:1.2.16:compile
[INFO]    +- org.glassfish.ha:ha-api:jar:3.1.12:compile
[INFO]    +- com.sun.xml.messaging.saaj:saaj-impl:jar:1.5.1:compile
[INFO]    +- com.fasterxml.woodstox:woodstox-core:jar:5.1.0:runtime
[INFO]    +- org.codehaus.woodstox:stax2-api:jar:4.1:runtime
[INFO]    \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.808 s
[INFO] Finished at: 2022-10-15T12:58:08-03:00
[INFO] ------------------------------------------------------------------------
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文