我尝试使用wsimport从WSDL生成类。
我正在使用Netbeans(7.1)生成的Maven POP,但是当我尝试构建它时,我得到以下输出:
[jaxws:wsimport]
Processing: C:\Users\...\src\wsdl\ShipService_v5.wsdl
jaxws:wsimport args: [-s, C:\Users\...\target\generated-sources\jaxws-wsimport, -d, C:\Users\...\target\classes, -verbose, -catalog, C:\Users\...\src\jax-ws-catalog.xml, -wsdllocation, file:/C:/Users/.../Desktop/ShipService_v5.wsdl, -extension, -Xnocompile, C:\Users\...\src\wsdl\ShipService_v5.wsdl]
parsing WSDL...
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.361s
Finished at: Mon Apr 09 12:51:52 BST 2012
Final Memory: 4M/120M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:jaxws-maven-plugin:1.10:wsimport (wsimport-generate-ShipService_v5) on project RPDataStreams: Error executing: wsimport [-s, C:\Users\...\target\generated-sources\jaxws-wsimport, -d, C:\Users\...\target\classes, -verbose, -catalog, C:\Users\...\src\jax-ws-catalog.xml, -wsdllocation, file:/C:/Users/.../Desktop/ShipService_v5.wsdl, -extension, -Xnocompile, C:\Users\...\src\wsdl\ShipService_v5.wsdl] -> [Help 1]
我POM的插件部分是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>ShipService_v5.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>file:/C:/Users/.../Desktop/ShipService_v5.wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/ShipService_v5.stale</staleFile>
</configuration>
<id>wsimport-generate-ShipService_v5</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>1.4</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>
我知道我使用的WSDL没有任何问题,我也尝试使用http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl的WSDL。
我尝试从Netbeans和Ubuntu服务器的命令行构建这个项目,两次都得到相同的结果。
我现在将其缩小到依赖于jconfig。如果我注释掉下面的块,那么Web服务源就会成功构建。
<dependency>
<groupId>org.jconfig</groupId>
<artifactId>jconfig</artifactId>
<version>2.9</version>
<exclusions>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
</exclusions>
</dependency>
感谢您的帮助。
答案 0 :(得分:6)
您应该使用:
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
这是最新版本(注意插件已移至org.jvnet.jax-ws-commons)
编辑:
您可以尝试有选择地排除jconfig构建依赖项。完整列表如下:
<dependency>
<groupId>org.jconfig</groupId>
<artifactId>jconfig</artifactId>
<version>2.9</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.parsers</groupId>
<artifactId>jaxp-api</artifactId>
</exclusion>
<exclusion>
<groupId>crimson</groupId>
<artifactId>crimson</artifactId>
</exclusion>
</exclusions>
</dependency>
编辑:你真的需要jconfig吗?如果没有,就摆脱它。
答案 1 :(得分:2)
您可能正在使用JRE而不是JDK。
请尝试更改JDK并再次运行maven build。
将JRE更改为JDK - http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx
答案 2 :(得分:0)
在项目运行配置的JRE选项卡中,选择备用JRE并添加已安装JDK的路径。 对我来说,这样做解决了这个问题。