Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.resolver.CatalogManager Java 11

I have a JavaFX application I was migrating from Java 8 to Java 11, it has been a rough transition but most of the application is working except for the web service, it keeps giving me the exception:

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
            at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
            at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
            at java.base/java.lang.Thread.run(Thread.java:834)
    Caused by: java.lang.NoClassDefFoundError: com/sun/org/apache/xml/internal/resolver/CatalogManager
            at com.sun.xml.ws.util.xml.XmlUtil.createDefaultCatalogResolver(XmlUtil.java:296)
            at com.sun.xml.ws.client.WSServiceDelegate.createCatalogResolver(WSServiceDelegate.java:348)
            at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:334)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:292)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:201)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:182)
            at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:178)
            at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:89)
            at javax.xml.ws.Service.<init>(Service.java:82)
            at e.bop.asycuda.WSMrrtService.<init>(WSMrrtService.java:39)
            at e.bop.main.EBop.start(EBop.java:56)
            at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
            at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
            at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
            at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
            at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
            at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
            ... 1 more
    Caused by: java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.resolver.CatalogManager
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
            ... 20 more

I have looked at similar question like this but to no avail. I have the following dependancy in my pom file

  <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.3.1</version>
        <type>pom</type>
    </dependency>
like image 463
Astonio Avatar asked Oct 10 '19 09:10

Astonio


2 Answers

This dependency contains the class com.sun.org.apache.xml.internal.resolver.CatalogManager that your project is not finding.

<dependency>
    <groupId>com.sun.org.apache.xml.internal</groupId>
    <artifactId>resolver</artifactId>
    <version>20050927</version>
</dependency>
like image 60
Carlos Avatar answered Oct 06 '22 00:10

Carlos


I had the same exceptions problems with a project after moving from Java 8 to Java 11.

These are the project settings:

  • The project is a client that access a server using soap web services
  • The web services of the server are generated via https://cxf.apache.org/ by using wsdl2java. The exception occurs by calling the generated sources
  • The project will be deployed to a standalone version by using the maven-assembly-plugin

Solution:

The only (and actually easiest) thing that worked for me was to enable multi release in the pom file:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>
                                    de.mycompany.testclient.CmdLineRunner
                                </mainClass>
                            </manifest>
                            <manifestEntries>
                                <!-- This fixed the CatalogManager exception problem -->
                                <Multi-Release>true</Multi-Release>
                            </manifestEntries>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

I did not add any dependencies related to com.sun.xml.ws

like image 24
Christof Nasahl Avatar answered Oct 05 '22 23:10

Christof Nasahl