Maven执行失败:无法执行目标org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport

8
以下是用于执行wsimport的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>com.dat</groupId>
  <artifactId>digsig</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>digsig</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-xjc -->
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-xjc</artifactId>
    <version>2.2.11</version>
</dependency>

    <dependency>
      <groupId>com.sun.xml.ws</groupId>
      <artifactId>jaxws-rt</artifactId>
      <version>2.2.8</version>
    </dependency>
  </dependencies>
  <build>    
    <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.3</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
              <silent>true</silent>
              <artifactItems>
                <artifactItem>
                  <groupId>javax.xml.bind</groupId>
                  <artifactId>jaxb-api</artifactId>
                  <version>2.2.7</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>javax.xml.ws</groupId>
                  <artifactId>jaxws-api</artifactId>
                  <version>2.2.9</version>
                  <type>jar</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jvnet.jax-ws-commons</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.3</version>
        <executions>
          <execution>
            <goals>
              <goal>wsimport</goal>
            </goals>
            <!-- Following configuration will pass all XML files from ${basedir}/src/bindings to wsimport. -->
            <configuration>
              <bindingDirectory>${basedir}/src</bindingDirectory>
              <vmArgs>
                <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
              </vmArgs>
              <wsdlUrls>
                <wsdlUrl>http://webservice.server/Services/InvoiceService.asmx?WSDL</wsdlUrl>
              </wsdlUrls>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>
</project>

构建失败,错误如下:

[DEBUG] Importing foreign packages into class realm plugin>org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3
[DEBUG]   Imported:  < maven.api
[DEBUG] Populating class realm plugin>org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3
[DEBUG]   Included: org.jvnet.jax-ws-commons:jaxws-maven-plugin:jar:2.3
[DEBUG]   Included: com.sun.xml.ws:jaxws-tools:jar:2.2.8
[DEBUG]   Included: org.jvnet.jaxb2_commons:jaxb2-basics:jar:0.6.4
[DEBUG]   Included: org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.6.4
[DEBUG]   Included: org.jvnet.jaxb2_commons:jaxb2-basics-tools:jar:0.6.4
[DEBUG]   Included: commons-beanutils:commons-beanutils:jar:1.7.0
[DEBUG]   Included: commons-lang:commons-lang:jar:2.2
[DEBUG]   Included: commons-logging:commons-logging:jar:1.1.1
[DEBUG]   Included: com.google.code.javaparser:javaparser:jar:1.0.8
[DEBUG]   Included: backport-util-concurrent:backport-util-concurrent:jar:3.1
[DEBUG]   Included: org.codehaus.plexus:plexus-interpolation:jar:1.11
[DEBUG]   Included: junit:junit:jar:3.8.1
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.5
[DEBUG]   Included: org.sonatype.sisu:sisu-inject-bean:jar:2.3.0
[DEBUG]   Included: org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0
[DEBUG]   Included: org.sonatype.sisu:sisu-guava:jar:0.9.9
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:3.0.10
[DEBUG] Configuring mojo org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport from plugin realm ClassRealm[plugin>org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3, parent: sun.misc.Launcher$AppClassLoader@55f96302]
[DEBUG] Configuring mojo 'org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport' with basic configurator -->
[DEBUG]   (f) bindingDirectory = D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\src
[DEBUG]   (f) destDir = D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\classes
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) extension = false
[DEBUG]   (f) genJWS = false
[DEBUG]   (f) implDestDir = D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\src\main\java
[DEBUG]   (f) keep = true
[DEBUG]   (f) localRepository =       id: local
      url: file:///c:/tools/maven/repository/
   layout: default
snapshots: [enabled => true, update => always]
 releases: [enabled => true, update => always]

[DEBUG]   (f) pluginArtifactMap = {org.jvnet.jax-ws-commons:jaxws-maven-plugin=org.jvnet.jax-ws-commons:jaxws-maven-plugin:maven-plugin:2.3:, com.sun.xml.ws:jaxws-tools=com.sun.xml.ws:jaxws-tools:jar:2.2.8:compile, org.jvnet.jaxb2_commons:jaxb2-basics=org.jvnet.jaxb2_commons:jaxb2-basics:jar:0.6.4:compile, org.jvnet.jaxb2_commons:jaxb2-basics-runtime=org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.6.4:compile, org.jvnet.jaxb2_commons:jaxb2-basics-tools=org.jvnet.jaxb2_commons:jaxb2-basics-tools:jar:0.6.4:compile, commons-beanutils:commons-beanutils=commons-beanutils:commons-beanutils:jar:1.7.0:compile, commons-lang:commons-lang=commons-lang:commons-lang:jar:2.2:compile, commons-logging:commons-logging=commons-logging:commons-logging:jar:1.1.1:compile, com.google.code.javaparser:javaparser=com.google.code.javaparser:javaparser:jar:1.0.8:compile, org.apache.maven:maven-project=org.apache.maven:maven-project:jar:2.2.1:compile, org.apache.maven:maven-settings=org.apache.maven:maven-settings:jar:2.2.1:compile, org.apache.maven:maven-profile=org.apache.maven:maven-profile:jar:2.2.1:compile, org.apache.maven:maven-model=org.apache.maven:maven-model:jar:2.2.1:compile, org.apache.maven:maven-artifact-manager=org.apache.maven:maven-artifact-manager:jar:2.2.1:compile, org.apache.maven:maven-repository-metadata=org.apache.maven:maven-repository-metadata:jar:2.2.1:compile, backport-util-concurrent:backport-util-concurrent=backport-util-concurrent:backport-util-concurrent:jar:3.1:compile, org.apache.maven:maven-plugin-registry=org.apache.maven:maven-plugin-registry:jar:2.2.1:compile, org.codehaus.plexus:plexus-interpolation=org.codehaus.plexus:plexus-interpolation:jar:1.11:compile, org.apache.maven:maven-artifact=org.apache.maven:maven-artifact:jar:2.2.1:compile, org.codehaus.plexus:plexus-container-default=org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile, junit:junit=junit:junit:jar:3.8.1:compile, classworlds:classworlds=classworlds:classworlds:jar:1.1-alpha-2:compile, org.apache.maven:maven-plugin-api=org.apache.maven:maven-plugin-api:jar:3.0.5:compile, org.sonatype.sisu:sisu-inject-plexus=org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:compile, org.codehaus.plexus:plexus-component-annotations=org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile, org.codehaus.plexus:plexus-classworlds=org.codehaus.plexus:plexus-classworlds:jar:2.4:compile, org.sonatype.sisu:sisu-inject-bean=org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:compile, org.sonatype.sisu:sisu-guice=org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile, org.sonatype.sisu:sisu-guava=org.sonatype.sisu:sisu-guava:jar:0.9.9:compile, org.codehaus.plexus:plexus-utils=org.codehaus.plexus:plexus-utils:jar:3.0.10:compile}
[DEBUG]   (f) quiet = false
[DEBUG]   (f) remoteRepositories = [      id: nexus
      url: http://passport-nexus/nexus/content/groups/public
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => never]
]
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@78e89bfe
[DEBUG]   (f) sourceDestDir = D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\generated-sources\wsimport
[DEBUG]   (f) staleFile = D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\jaxws\stale
[DEBUG]   (f) verbose = false
[DEBUG]   (f) vmArgs = [-Djavax.xml.accessExternalSchema=all]
[DEBUG]   (f) wsdlDirectory = D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\src\wsdl
[DEBUG]   (f) wsdlUrls = [http://webservice.server/Services/InvoiceService.asmx?WSDL]
[DEBUG]   (f) xadditionalHeaders = false
[DEBUG]   (f) xdebug = false
[DEBUG]   (f) xdisableAuthenticator = false
[DEBUG]   (f) xdisableSSLHostnameVerification = false
[DEBUG]   (f) xnoAddressingDataBinding = false
[DEBUG]   (f) xnocompile = true
[DEBUG]   (f) xuseBaseResourceAndURLToLoadWSDL = false
[DEBUG]   (f) project = MavenProject: com.dat:digsig:0.0.1-SNAPSHOT @ D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\pom.xml
[DEBUG] -- end configuration --
[DEBUG] The wsdl Directory is D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\src\wsdl
[DEBUG] The binding Directory is D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\src
[INFO] Processing: http://webservice.server/Services/InvoiceService.asmx?WSDL
[DEBUG] adding src root: D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\generated-sources\wsimport
[DEBUG] The binding Directory is D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\src
[DEBUG] jaxws:wsimport args: [-keep, -s, D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\generated-sources\wsimport, -d, D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\classes, -encoding, UTF-8, -Xnocompile]
[INFO] jaxws:wsimport args: [-keep, -s, D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\generated-sources\wsimport, -d, D:\Dev\Eclipse_Workspace\Neon\WebService_Demo\digsig\target\classes, -encoding, UTF-8, -Xnocompile, "http://webservice.server/Services/InvoiceService.asmx?WSDL"]
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[WARNING] Failed to build parent project for com.sun.xml.ws:project:pom:2.2.8
[WARNING] Failed to build parent project for com.sun.xml.ws:bundles:pom:2.2.8
[WARNING] Failed to build parent project for com.sun.xml.ws:jaxws-tools:pom:2.2.8
[WARNING] Invalid POM for com.sun.xml.ws:jaxws-tools:jar:2.2.8, transitive dependencies (if any) will not be available, enable debug logging for more details: 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, c:\tools\maven\repository\com\sun\xml\ws\jaxws-ri-bom\2.2.8\jaxws-ri-bom-2.2.8.pom, line 395, column 29

[DEBUG]   com.sun.xml.ws:jaxws-tools:jar:2.2.8:compile (selected for compile)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.747 s
[INFO] Finished at: 2017-02-27T16:47:38-06:00
[INFO] Final Memory: 12M/364M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (default) on project digsig: Execution default of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: String index out of range: -1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport (default) on project digsig: Execution default of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: String index out of range: -1
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3:wsimport failed: String index out of range: -1
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.AbstractStringBuilder.substring(Unknown Source)
    at java.lang.StringBuilder.substring(Unknown Source)
    at org.jvnet.jax_ws_commons.jaxws.AbstractJaxwsMojo.getCP(AbstractJaxwsMojo.java:484)
    at org.jvnet.jax_ws_commons.jaxws.AbstractJaxwsMojo.exec(AbstractJaxwsMojo.java:359)
    at org.jvnet.jax_ws_commons.jaxws.WsImportMojo.processWsdlViaUrls(WsImportMojo.java:342)
    at org.jvnet.jax_ws_commons.jaxws.WsImportMojo.execute(WsImportMojo.java:282)
    at org.jvnet.jax_ws_commons.jaxws.MainWsImportMojo.execute(MainWsImportMojo.java:50)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    ... 21 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

有人能帮我解决这个问题吗?


你能否尝试在pom.xml文件中添加这个仓库 https://mvnrepository.com/artifact/org.jvnet.jax-ws-commons/jaxws-maven-plugin? - mibrahim.iti
我刚刚将插件添加到我的测试pom.xml文件中,我认为问题来自于您使用的文件不在Maven插件本身中。 - mibrahim.iti
在你的 settings.xml 文件中,是否有任何依赖管理的值为 ${tools.jar}? - Adonis
@RanPaul,你有什么解决方案吗?我正在面临完全相同的问题。 - Haripriya
@PriyankaW 我用 Gradle 代替 Maven 解决了它。 - OTUser
1
@RanPaul 谢谢你的更新。我正在寻找基于Maven的解决方案。 - Haripriya
3个回答

11

我通过降低JDK版本来解决了这个错误。右键单击你的项目>属性>构建>编译>Java平台>将其设置为JDK 1.8。


1
有时会因为找不到类而发生异常。
  1. 点击wsgen错误,然后您可以看到更多详细信息
  2. 检查构建失败的位置
  3. 检查sei标签(在pom.xml中)中的类是否引用了正确的服务。它应该指向源代码(src)中的正确路径。
这解决了我的问题。

1

如果您的目标是JDK 17,那么您只需替换

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

使用

        <plugin>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>4.0.1</version>
            ...

重新加载POM并重新编译。
我正在寻找一种更新NetBeans 18的方法。
新建文件 > Web服务 > Web服务客户端
模板,这样我就不必手动修改pom.xml了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接