1

I'm getting a NoClassDefFoundError for a class that exists in Oracle's rt.jar, but doesn't seem to exist in WebSphere's rt.jar.

java.lang.NoClassDefFoundError: com/sun/org/apache/xpath/internal/NodeSet

My understanding of WebSphere is that native java classes should exist in WebSphere's java installation, but that doesn't appear to be the case.

What's strange is that this works in one environment and doesn't work in another - but neither of the rt.jar files have the NodeSet class. I would think this wouldn't work in either, as both have the WebSphere's JAVA_HOME environment variable set to the WebSphere java folder.

Does anybody have any ideas what might be happening here? Does WebSphere only use the java path in the WebSphere environment variable? Or does it use the server's environment variables as well?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Corey
  • 60
  • 9
  • 1
    Do you know what's trying to load that? Your own code or some other library in your app? Maybe someone could help find an alternative. Maybe a stack trace would help if you're not sure. – Scott Kurz Sep 15 '16 at 15:38
  • Yes, it's my own code. I think I could rewrite it to work with IBM's JDK, but then I don't know if it would need to make sure it also worked with Oracle's JDK, and I know it worked in the past, so it makes me think at some point it was reading from Oracle's JDK from WebSphere somehow. – Corey Sep 15 '16 at 16:17
  • Are you using traditional WebSphere or WebSphere Liberty? Traditional WebSphere will only work with the IBM JDK that comes with it. For WebSphere Liberty you can use whatever JDK you want. – Andy Guibert Sep 15 '16 at 19:39
  • What is the version of JDK that you are using? In the machine, where it works with the IBM JDK, see where it is loaded from. Turn on verbose class loading and the logs would tell you where the class is loaded from. – Manglu Sep 16 '16 at 06:06
  • Why, at all, are you coding against specific XML-parser implementation? You should not be doing this in the first place. Work with standard APIs. – ᄂ ᄀ Oct 12 '16 at 15:39

2 Answers2

1

WebSphere (especially traditional WebSphere) uses an IBM JDK.

The IBM JDK and the Oracle JDK differ in terms of XML providers. Information about using XML with the IBM JDK is here (note this is for JDK 8, may have to go back a bit from here):

https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.win.80.doc/user/xml/using_xml.html

ebullient
  • 1,250
  • 7
  • 16
0

This kind of issue usually happens when you have stale jars in the classpath or bootclasspath. In the failed environment, the exception was thrown from a class which could be loaded from a stale jar and it expects an Oracle XML implementation.