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

生成WAR包时遇com.sun.xml.internal.ws.developer包不存在错误求助

Hey there, let's work through this problem you're facing with the WSBindingProvider class and your WAR build. I've got a couple of solid solutions for you, both fixing the compile error upfront and modifying the code post-WAR if you need that.

Fixing the com.sun.xml.internal.ws.developer.WSBindingProvider Compile Error

First, let's address why this error pops up: the com.sun.xml.internal packages are internal JDK APIs, meaning they're not meant for public use—different JDK versions might hide or remove them entirely, which breaks your build. Here's how to fix it properly:

The public, supported version of this class lives in com.sun.xml.ws.developer.WSBindingProvider (note the missing internal). To use this:

  1. Update your import statement to remove internal:
    import com.sun.xml.ws.developer.WSBindingProvider;
    
  2. Add the official JAX-WS runtime dependency to your build file:
    • For Maven, add this to your pom.xml:
      <dependency>
          <groupId>com.sun.xml.ws</groupId>
          <artifactId>jaxws-rt</artifactId>
          <version>2.3.3</version> <!-- Use the latest compatible version -->
          <scope>provided</scope> <!-- Mark as provided if your server already includes it -->
      </dependency>
      
    • For Gradle, add this to your build.gradle:
      implementation 'com.sun.xml.ws:jaxws-rt:2.3.3'
      

This ensures you're using a supported API that won't break across JDK versions.

If you absolutely need to keep using the internal package (I'd advise against this for long-term compatibility), you can tell your compiler to allow access to internal JDK classes:

  • For Maven, update the maven-compiler-plugin in your pom.xml:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <compilerArgs>
                <arg>-XDignore.symbol.file</arg>
            </compilerArgs>
        </configuration>
    </plugin>
    

This skips the JDK's symbol file check, letting you compile against internal APIs. Just remember this could break if you upgrade your JDK later.

Modifying Classes After Generating the WAR File

If you already have a WAR and need to comment out the WSBindingProvider code without rebuilding from source, here's how to do it:

  1. Extract the WAR contents
    Use a tool like unzip (or any archive manager) to unpack the WAR into a directory:

    unzip your-project.war -d war-extracted
    
  2. Locate the compiled class file
    Navigate to war-extracted/WEB-INF/classes and find the .class file corresponding to your Java class (e.g., com/example/MyService.class if your class is com.example.MyService).

  3. Decompile the class to Java code
    Use a decompiler tool like JD-GUI (local, offline tool is safest) to convert the .class file back into readable Java code. Once decompiled, comment out the import statement and any code that uses WSBindingProvider.

  4. Recompile the modified Java file
    Compile the updated .java file, making sure to include all your project's dependencies (from WEB-INF/lib):

    javac -cp "war-extracted/WEB-INF/lib/*:war-extracted/WEB-INF/classes" com/example/MyService.java
    
  5. Replace the original class file
    Copy the newly compiled .class file back into the war-extracted/WEB-INF/classes directory, overwriting the original.

  6. Recreate the WAR file
    Navigate back to the extracted directory and re-zip everything into a new WAR:

    cd war-extracted
    zip -r ../your-modified-project.war .
    

A quick note: This is a temporary fix. Whenever possible, modify the source code and rebuild the WAR properly—it's easier to maintain and less error-prone.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 04:04:18