Expand my Community achievements bar.

ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl in AEM cloud instance

Avatar

Level 1

Hi All, We are implementing a SOAP call in our application and building the project using Java 11, in which while making a call to the SOAP API we get the following error. Please help us to resolve this issue.
Error

java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl not found by org.apache.felix.http.jetty

I tried adding the dependency of com.sun.xml to my POM files and installed it as a separate osgi bundle as well, but it didn't help

<dependency>

<groupId>com.sun.xml.ws</groupId>

<artifactId>jaxws-rt</artifactId>

<version>2.3.5</version>

</dependency>

<dependency>

<groupId>com.sun.xml.ws</groupId>

<artifactId>jaxws-ri</artifactId>

<version>2.3.5</version>

<type>pom</type>

</dependency>

<dependency>

<groupId>com.sun.xml.ws</groupId>

<artifactId>rt</artifactId>

<version>2.3.5</version>

</dependency>

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Level 6

Hi @saravanan_ms ,

The error java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl indicates that the required JAX-WS implementation is not accessible to the AEM classloader. This happens because the Java runtime in AEM is modularized, and dependencies need to be explicitly managed in the OSGi framework.

Problem Analysis

The class com.sun.xml.internal.ws.spi.ProviderImpl is part of the JAX-WS reference implementation, and its absence in the OSGi environment suggests:

  1. The required libraries are not correctly packaged as OSGi bundles.
  2. The dependencies are not resolving properly in the OSGi container due to missing metadata in the bundle or incorrect configurations.

Solution

1. Use a Compatible JAX-WS Implementation

The dependency jaxws-rt (runtime) and jaxws-ri (reference implementation) from com.sun.xml.ws are correct choices. However, they need proper OSGi metadata.

Convert JARs to OSGi Bundles

Ensure your JAX-WS libraries are OSGi-compliant:

  1. Use the Apache Felix Maven Bundle Plugin to wrap non-OSGi JARs into OSGi bundles.

 

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>5.1.6</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>com.sun.xml.ws.jaxws-rt</Bundle-SymbolicName>
                    <Export-Package>
                        com.sun.xml.internal.ws.spi;version="2.3.5",
                        com.sun.xml.ws.*;version="2.3.5"
                    </Export-Package>
                    <DynamicImport-Package>*</DynamicImport-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>

 

  • Deploy the resulting OSGi bundle into AEM.

2. Adjust SlingServlet to Load the Provider

Explicitly set the JAX-WS provider in your code: System.setProperty("javax.xml.ws.spi.Provider", "com.sun.xml.internal.ws.spi.ProviderImpl");

3. Handle Classloading in AEM

Ensure your bundle imports the required packages. Update the Import-Package statement in your POM:

 

<Import-Package>
    com.sun.xml.internal.ws.spi,
    javax.xml.ws.spi,
    *
</Import-Package>

 

4. Verify SOAP Library in Runtime

After deploying the bundle, confirm that the required classes are available:

  1. Go to AEM Web Console  Bundles (http://<host>:<port>/system/console/bundles).
  2. Check if the JAX-WS libraries are installed and active.

5. Debug the Resolution Issues

Enable OSGi debug logging to track classloader issues:

  1. Open AEM Web Console  Log Support.
  2. Add a logger for org.apache.felix.framework at DEBUG level.

Also you can check this article: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/invoking-soap-web-services... 

 

Best regards,

Kostiantyn Diachenko.

Avatar

Community Advisor

hi @saravanan_ms 

 

Can you please try adding below dependencies :

 

<dependencies>
    <!-- JAX-WS API -->
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>javax.xml.ws-api</artifactId>
        <version>2.3.1</version> <!-- Choose the appropriate version -->
    </dependency>

    <!-- JAX-WS Runtime (provided by Metro) -->
    <dependency>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>jaxws-ri</artifactId>
        <version>2.3.2</version> <!-- Or the latest version -->
    </dependency>

    <!-- JAX-WS Runtime (Optional for SOAP Handler) -->
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.3</version>
    </dependency>
</dependencies>