You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行Maven的generate-sources目标时抛出InvocationTargetException错误求助

Troubleshooting InvocationTargetException During mvn generate-sources for JAX-WS Web Service

Hey there! Let's break down this issue you're facing with your NetBeans/GlassFish/Maven JAX-WS project. The InvocationTargetException you're seeing is actually a wrapper exception—it doesn't tell you the real problem on its own. It just means something went wrong inside a method invoked via reflection, and the actual root cause is hidden in the nested stack trace.

Here's how to get to the bottom of this:

1. First, Get the Full Error Stack Trace

The error log you shared cuts off early, so we need the complete picture. Run your Maven command with the -e flag to enable full stack trace output:

mvn clean generate-sources -e

Look for lines starting with Caused by:—that's where you'll find the actual error (like missing WSDL files, dependency conflicts, or plugin misconfigurations).

2. Common Root Causes & Fixes for Your Stack

Based on your setup (JAX-WS + Maven + GlassFish), these are the most likely culprits:

a. JAX-WS Maven Plugin Misconfiguration or Version Mismatch

The jaxws-maven-plugin (used for generating sources from WSDL) often causes issues if its version doesn't align with your JDK or GlassFish version. For example:

  • JDK 8 works best with plugin version 2.3
  • JDK 11+ requires switching to Jakarta EE-compatible plugins (since JAX-WS was moved to the Jakarta namespace)

Double-check your pom.xml plugin configuration. Here's a standard working setup for JDK 8/GlassFish 5:

<plugin>
  <groupId>org.jvnet.jax-ws-commons</groupId>
  <artifactId>jaxws-maven-plugin</artifactId>
  <version>2.3</version>
  <executions>
    <execution>
      <goals>
        <goal>wsimport</goal>
      </goals>
      <configuration>
        <!-- Make sure this path points to your actual WSDL file -->
        <wsdlFiles>
          <wsdlFile>src/main/resources/your-service.wsdl</wsdlFile>
        </wsdlFiles>
        <packageName>com.yourcompany.ws.generated</packageName>
      </configuration>
    </execution>
  </executions>
</plugin>

b. Dependency Conflicts with GlassFish

GlassFish includes its own JAX-WS implementation libraries. If your Maven project pulls in conflicting versions of JAX-WS APIs or implementations (like jaxws-api, jaxrt, or com.sun.xml.ws), this can cause runtime/compile-time errors.

Fix this by marking conflicting dependencies as provided (since GlassFish supplies them):

<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.3.1</version>
  <scope>provided</scope>
</dependency>

c. Invalid or Missing WSDL File

If you're generating sources from a WSDL, ensure:

  • The WSDL file path in your plugin config is correct (relative to your project root)
  • The WSDL file itself is valid (no XML syntax errors, all schema references are resolvable)
  • If the WSDL is hosted remotely, your build machine has access to the URL, and there are no SSL issues

d. NetBeans Cache or Integration Glitch

Sometimes NetBeans' internal Maven cache can cause weird issues. Try:

  • Running the Maven command directly from your terminal (outside NetBeans) to rule out IDE-specific problems
  • Clearing NetBeans cache: Go to Help > About > Installation > Cache Directory, delete the cache folder, then restart NetBeans

Next Steps

Once you have the full stack trace (especially the Caused by: section), share that plus the relevant parts of your pom.xml (JAX-WS plugin config and dependencies), and we can pinpoint the exact issue.

内容的提问来源于stack exchange,提问作者user9166119

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:26:25