【问题标题】:Jaxb Xew Plugin in Maven JAX WSMaven JAX WS 中的 Jaxb Xew 插件
【发布时间】:2014-05-16 09:11:22
【问题描述】:
mvn generate-sources
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder          org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBu
ilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building epay_api 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jaxws-maven-plugin:2.3:wsimport (wsimport-generate-sources) @ api ---
[INFO] Processing: file:/C:/service.wsdl
[WARNING] Using platform encoding (Cp1256), build is platform dependent!
[INFO] jaxws:wsimport args: [-keep, -s, C:\api\src\main\java, -d, C:\api\target\classes,     -verbose, -Xnocompile, -B-debug, -B-no-header, -B-Xxew, -B-Xx
ew:instantiate lazy, -B-Xxew:delete, -B-extension, -B-b C:\api/src/main/res
ources/jaxb_binding.xml, "file:/C:/api/src/main/resources/service.w
sdl"]
[DEBUG] JAXB Compilation started (XmlElementWrapperPlugin.onActivated):
[DEBUG]   buildId         : 2.2.7
[DEBUG]   targetDir       : .
[DEBUG]   defaultPackage  : null
[DEBUG]   defaultPackage2 : null
[DEBUG]   debug           : true
[DEBUG]   verbose         : true
[DEBUG]   quiet           : false
[DEBUG]   grammars        : 0
[DEBUG] Argument[0] = -Xxew
[DEBUG] Argument[0] = -Xxew:instantiate
[DEBUG] Argument[0] = -Xxew:delete
parsing WSDL...


Exception in thread "main" java.lang.ClassCastException: java.lang.NoSuchMethodError     cannot be cast
to java.lang.Exception
        at org.jvnet.jax_ws_commons.jaxws.Invoker.main(Invoker.java:87)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.593 s
[INFO] Finished at: 2014-04-04T04:06:54+04:00
[INFO] Final Memory: 7M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport     (wsimport-ge
nerate-sources) on project epay_api: Mojo failed - check output -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the     following arti
cles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这是我的简单 pom.xml

<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>api</groupId>
<artifactId>api</artifactId>
<version>0.0.1-SNAPSHOT</version>

<build>

    <plugins>
        <plugin>
            <groupId>org.jvnet.jax-ws-commons</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <id>wsimport-generate-sources</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <verbose>true</verbose>
                        <sourceDestDir>src/main/java</sourceDestDir>
                        <wsdlDirectory>src/main/resources/</wsdlDirectory>
                        <wsdlLocation>src/main/resources/*</wsdlLocation>
                        <xjcArgs>
                            <xjcArg>-debug</xjcArg>
                            <xjcArg>-no-header</xjcArg>

                            <xjcArg>-Xxew</xjcArg>
                            <xjcArg>-Xxew:instantiate lazy</xjcArg>
                            <xjcArg>-Xxew:delete</xjcArg>

                            <xjcArg>-extension</xjcArg>
                            <xjcArg>-b ${basedir}/src/main/resources/jaxb_binding.xml</xjcArg>
                            <xjcArg>-XJsr303Annotations</xjcArg>
                            <!-- <xjcArg>-Xfluent-api</xjcArg> -->
                            <!-- <xjcArg>-Xvalue-constructor</xjcArg> -->
                        </xjcArgs>

                    </configuration>


                </execution>

            </executions>
            <dependencies> 
                <dependency>
                    <groupId>com.github.jaxb-xew-plugin</groupId>
                    <artifactId>jaxb-xew-plugin</artifactId>
                    <version>1.2</version>
                </dependency>

                <dependency>
                    <groupId>com.github.krasa</groupId>
                    <artifactId>krasa-jaxb-tools</artifactId>
                    <version>1.1</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins>

</build>

而且 -e -X 开关不会显示有关此错误的任何信息

"main" java.lang.ClassCastException: java.lang.NoSuchMethodError 不能被强制转换 在 .jax_ws_commons.jaxws.Invoker.main(Invoker.java:87)

这是我正在尝试的最基本的配置。

C:\api>java -version java版本“1.7.0_51” Java(TM) SE 运行时环境 (build 1.7.0_51-b13) Java HotSpot(TM) 64 位服务器 VM(内部版本 24.51-b03,混合模式)

C:\api>mvn -version 阿帕奇 Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T21:37:52+04:00) Maven 主页:C:\Program Files\apache-maven-3.2.1\bin.. Java 版本:1.7.0_51,供应商:甲骨文公司 Java 主页:C:\Program Files\Java\jdk1.7.0_51\jre 默认语言环境:en_US,平台编码:Cp1256 操作系统名称:“windows 7”,版本:“6.1”,arch:“amd64”,家族:“windows”

我的配置有什么问题?感谢任何帮助谢谢

【问题讨论】:

  • 我遇到了类似的问题。使用 Ant 而不是 Maven 插件,但本质保持不变。我必须将 commons-logging-api-1.1.jar 添加到类路径中才能使其工作。 HTH。

标签: jaxb2 jaxws-maven-plugin jaxb-xew-plugin


【解决方案1】:

尝试在你的 pom.xml 中添加这个插件

<plugin>
    <groupId>org.jvnet.jax-ws-commons</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <!-- Needed with JAXP 1.5 -->
        <vmArgs>
            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
        </vmArgs>
    </configuration>
</plugin>

【讨论】:

    【解决方案2】:

    我得到了同样的错误:

    未能执行目标 org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (默认) on 项目 birst-soap-client: Mojo 失败 - 检查输出。

    但原因在于 Jenkins。 Jenkins 作业名称中有一些空格(“file:/data/jenkins/workspace/Dpm-Flyer-Core%20-%20Release%20Tag+Nexus/...),这导致无法执行“jaxws: wsimport”。 但奇怪的是,Jenkins 将其列为 [INFO] 而不是 [ERROR]。 删除 Jenkins 作业名称中的空格后。构建成功执行。 摘录如下。

    [INFO] [INFO] 处理: 文件:/data/jenkins/workspace/Dpm-Flyer-Core%20-%20Release%20Tag+Nexus/thirdparty/birst-soap-client/src/main/resources/wsdl/CommandWebService.5.19.wsdl [INFO] [WARNING] 使用平台编码 (UTF-8),构建是平台 依赖! [信息] [信息] jaxws:wsimport 参数:[-keep,-s, /data/jenkins/workspace/Dpm-Flyer-Core - 发布 Tag+Nexus/thirdparty/birst-soap-client/target/generated-sources/wsimport, -d, /data/jenkins/workspace/Dpm-Flyer-Core - 发布 Tag+Nexus/thirdparty/birst-soap-client/target /类,-详细, -Xnocompile, -B-XautoNameResolution, -p, com.birst, -target, 2.0, "file:/data/jenkins/workspace/Dpm-Flyer-Core%20-%20Release%20Tag+Nexus/thirdparty/birst-soap -client/src/main/resources/wsdl/CommandWebService.5.19.wsdl"] [INFO] 目录未找到:/data/jenkins/workspace/Dpm-Flyer-Core

    【讨论】:

      【解决方案3】:

      https://java.net/jira/browse/JAX_WS_COMMONS-129 的解决方法帮助了我:

          <configuration>
               <vmArgs>
                  <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
               </vmArgs>
          </configuration>
      

      【讨论】:

      • 为我工作!但是……为什么?
      【解决方案4】:

      对于它的价值:我遇到了同样的错误 - 使用 Maven 3.2.2 并且我将 jaxws-maven-plugin 设置为 2.3。这停止了​​解决问题:

      线程“main”java.lang.ClassCastException 中的异常:java.lang.NoSuchMethodError 无法转换为 java.lang.Exception

      阅读线程和 Stack Overflow 帖子,似乎使用新版本的插件会有所帮助。一直移动到 2.3.1-b01 到 2.3.1-b03。这将问题更改为现在导致:

      java.lang.NoClassDefFoundError: org/sonatype/aether/* 引起:java.lang.ClassNotFoundException: org.sonatype.aether.*

      似乎 2.3.1-b03 与 >=3.1 的任何 Maven 版本一起工作时存在一个有据可查的问题。您可以通过搜索找到更多信息(上面有 JIRA 和错误报告)或启动 here

      最终我又回到了 2.2。对于插件,这没有问题。

      【讨论】:

      • 从 2.3 移回 2.2 也为我修复了它
      • @BoneSmuggler - 我正在使用 org.jvnet.jax-ws-commons 的 jaxws-maven-plugin。对于 2.3.1-b03 中的 org.sonatype.aether 错误,您有任何解决方法吗?
      【解决方案5】:

      根据samples of the jaxb xew plugin,您需要使用更新版本的jaxws maven plugin。该示例使用版本 2.3.1-b03,它也在我的项目中工作。该插件的旧版本可能是针对与 jaxb xew plugin 不兼容的库编译的。

      如果您浏览示例代码历史记录,您也会发现 jaxws maven 插件版本 2.2 的配置。

      【讨论】:

      • 我同意最简单的解决方案是使用更新版本的jaxws-maven-plugin。旧版本是针对“旧”jaxb-xjc 编译的,但有一些怪癖我认为可以使 v2.3 工作。
      猜你喜欢
      • 1970-01-01
      • 2016-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 1970-01-01
      • 2011-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多