1

我想用 maven 执行 wsdl2java 但我有以下构建失败:

    [INFO] --- maven-dependency-plugin:2.1:copy (default) @ mogopay ---
[INFO] Configured Artifact: javax.xml.bind:jaxb-api:2.2:jar
[INFO] Configured Artifact: javax.xml.ws:jaxws-api:2.2:jar
[INFO] Copying jaxb-api-2.2.jar to c:\Users\EBIZNEXT\git\mogopay-core\mogopay\target\endorsed\jaxb-api-2.2.jar
[INFO] Copying jaxws-api-2.2.jar to c:\Users\EBIZNEXT\git\mogopay-core\mogopay\target\endorsed\jaxws-api-2.2.jar
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (copy-tomcat-resources) @ mogopay ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO]
[INFO] --- cxf-codegen-plugin:2.4.2:wsdl2java (CXF Payline) @ mogopay ---
[INFO] Running wsdl2java in fork mode...
[INFO] Building jar: C:\Users\EBIZNEXT\AppData\Local\Temp\cxf-tmp-679212\cxf-codegen5225275003143491559.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:30.351s
[INFO] Finished at: Tue Jan 22 18:28:57 CET 2013
[INFO] Final Memory: 14M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.4.2:wsdl2java (CXF Payline) on project mogopay:
[ERROR] Exit code: 1 - Exception in thread "main" org.apache.cxf.tools.common.ToolException: java.lang.reflect.UndeclaredThrowableException
[ERROR] at
   ...
[ERROR] Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElementRef.required()
[ERROR] at java.lang.Class.getDeclaredMethod(Class.java:1954)
[ERROR] at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:107)
[ERROR] ... 27 more
[ERROR]
[ERROR] Command line was: "c:\Program Files\Java\jdk1.7.0\jre\bin\java.exe" -Djava.endorsed.dirs=c:\Users\EBIZNEXT\git\mogopay-core\mogopay\target/endorsed -jar
 C:\Users\EBIZNEXT\AppData\Local\Temp\cxf-tmp-679212\cxf-codegen5225275003143491559.jar C:\Users\EBIZNEXT\AppData\Local\Temp\cxf-tmp-679212\cxf-w2j3628405823287
641812args

这个项目是在 grails 2.0.3 中构建的。问题似乎来自 Jaxb,因为 grails 中的当前版本使用 jaxb-api-2.1,而项目需要 jaxb 2.2。我已经更新了我的 pom,正如这个答案所建议的那样:Set Java Compliance Level in CXF wsdl2java和这里:Example 7 - Using JAXB/JAX-WS 2.2 with Java 6。但是当我执行 maven command : 时mvn clean install,我得到了上面的错误。

这是我的 pom(我删除了不重要的部分):

<pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArguments>
                        <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkMode>once</forkMode>
                    <argLine>-Djava.endorsed.dirs=${project.build.directory}/endorsed</argLine>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

         <plugins>
             ...
             <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax.xml.bind</groupId>
                                <artifactId>jaxb-api</artifactId>
                                <version>2.2</version>
                            </artifactItem>
                            <artifactItem>
                                <groupId>javax.xml.ws</groupId>
                                <artifactId>jaxws-api</artifactId>
                                <version>2.2</version>
                            </artifactItem>
                        </artifactItems>
                        <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin> 
                ...
               <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.4.2</version>
            <configuration>
                <fork>once</fork>
                <additionalJvmArgs>-Djava.endorsed.dirs=${project.build.directory}/endorsed</additionalJvmArgs>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                    <version>2.8.1</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <version>2.2</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-xjc</artifactId>
                    <version>2.2</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>CXF Payline</id>
                    <phase>process-resources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/java/wsdl/Payline_DirectPaymentAPI.wsdl</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>                
         </plugins>

任何建议将不胜感激

4

1 回答 1

1

Java 7 已经包含 jaxb 2.2(实际上是 2.2.4-1,如您在此处看到的),因此您不需要向该工件添加任何依赖项。如果此工件与 grails 2.0.3 依赖项冲突,请尝试从 grails 依赖项中排除 jaxb,也许 grails 对 jaxb 2.2 感到满意。

这应该是评论,但我开始使用过滤 javascript 的代理,我无法使用评论功能。对不起我的英语!

于 2013-01-23T11:53:26.417 回答