Tom Castelli
Tom Castelli

Reputation: 1

Upgrading from Java 8 to Java 11: NoClassDefFoundError: javax/activation/DataSource

I'm working on upgrading a project from Java 8 to Java 11.

The project uses an ant build script that calls wsimport, which I've found has been deprecated and is no longer included with the JDK. Not to worry, I am assured, I can add the libraries to the classpath and use the new wsimport.sh script and everything should be fine.

Except, it isn't.

The project includes generated code, for which we get a WSDL file from another source. It appears that that WSDL file uses the javax imports rather than the newer jakarta imports. So, upgrading from javax to jakarta is out.

Currently, when I run my wsimport.sh on the WSDL file, I get a screen full of Java stack trace which starts with:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource

Professor Google tells me that this is a result of not having some version of activation.jar in my classpath, but I've got a javax.activation.jar sitting right there in my lib directory. Breaking open the wsimport.sh, I've even added -cp ./lib/* to the java executable call. No luck.

Results also say I just need to "update my Maven dependencies," which may as well be Greek. I don't think we're using Maven.

In my seemingly exhaustive search of Google and StackOverflow, I was eventually directed to this blog post:

https://nipafx.dev/java-11-migration-guide/

...which, in the section on removal of Java EE modules, reads, in part:

"If you get it past the compiler but forget to massage the run time, you'll get a NoClassDefFoundError:"

What exactly does the post's author mean by "massage the run time?" I've verified I'm using a Java 11 JDK and java executable using java -version and java -XshowSettings:properties. The latter even shows the javax.activation.jar being loaded into the classpath. As far as I know, I've done nothing relating to a JRE. Do I need to?

I suspect this MAY be a version mismatch between my JAXB-RI and my jaxws-tools.jar file, but I haven't been able to find a listing of version compatibilities.

I feel like I am missing something obvious, but Java was never my strong suit. What is it I'm missing?


Some added details to answer questions posed in comments:

This is a standalone, self-contained desktop app. I'm using JAXWS-RI v2.3.1 and javax.activation.jar v1.2.0. It looks like the code is trying to use javax.xml.bind classes and not org.glassfish.jaxb classes. Adding the classpath entry to the ant build.xml file just caused a failed to create task or type classpathentry error.

I should add that I'm working on a specific part of the build that runs wsimport.sh on a given WSDL file. I've edited that shell script to use the Java 11 java executable rather than the Java 8 one. The script is successfully called by ant using the build.xml file (when running make), but I get the Java NoClassDefFound error at the wsimport.sh step. I'm debugging by running wsimport.sh standalone at the command line.

Upvotes: 0

Views: 284

Answers (0)

Related Questions