ClassNotFoundException in Saxon 10.5 PE's XPathFactoryImpl constructor when run in Eclipse debug mode
Added by Kai Weber over 3 years ago
When running my application in Eclipse's debug mode, the default constructor of XPathFactoryImpl throws a ClassNotFoundException pointing to nu.xom.Node being the missing class. I am using Saxon 10.5 PE and Eclipse 2020-06, and I read in the Saxon documentation:
In the JAXP XPath API, Saxon's implementation of XPathFactory now automatically registers JDOM, DOM4J, and XOM as supported external object models if a Saxon-PE or Saxon-EE configuration is in use.
Do I need to add XOM to the classpath if I want to use Saxon-PE? I would have expected the registration of XOM to be skipped when no XOM is availablae on the classpath. This behaviour seems to be related with Eclipse's debug mode and the reflection and/or wrapping of code that Eclipse would have to do in order to do some debugging. The ClassNotFoundException is not thrown when running the application in normal mode, either inside or outside of Eclipse.
Does anybody know about this behaviour and has a tip for how to circumvent this?
Replies (4)
Please register to reply
RE: ClassNotFoundException in Saxon 10.5 PE's XPathFactoryImpl constructor when run in Eclipse debug mode - Added by Michael Kay over 3 years ago
I haven't seen this before: but nothing to do with Eclipse and its class loaders would surprise me.
It looks as if the Eclipse ClassLoader is throwing a different exception from the one we're expecting. But looking at the code, I thought we were catching everything, so I'm not sure. Can you post a stack trace?
You might be able to work around it by registering your own IDynamicLoader with the Configuration (subclassing net.sf.saxon.trans.DynamicLoader) , and intercepting the call on getClass() in your IDynamicLoader.
RE: ClassNotFoundException in Saxon 10.5 PE's XPathFactoryImpl constructor when run in Eclipse debug mode - Added by Kai Weber over 3 years ago
Here's a stacktrace:
Konverter [Java Application]
de.paginagmbh.parsx.Konverter.Konverter at localhost:57725
Thread [main] (Suspended (uncaught exception ClassNotFoundException))
owns: ParsxFile (id=33)
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: 436
Launcher$AppClassLoader.loadClass(String, boolean) line: 349
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 357
JavaPlatformPE.registerAllBuiltInObjectModels(Configuration) line: 137
XPathFactoryImpl.<init>() line: 37
ParsxFile(XmlFile).evaluateXPath2(String, Node, QName) line: 96
ParsxFile(XmlFile).evaluateXPath2(String, QName) line: 102
ParsxFile(XmlFile).getNodelistFromXPathExpressions(ArrayList<String>) line: 174
FileManager.getParsxAusgaben() line: 245
FileManager.getInputXml() line: 164
Konverter.<init>(CommandLine) line: 209
Konverter.main(String[]) line: 112
C:\Program Files\Java\jdk1.8.0_211\bin\javaw.exe (20.08.2021 16:31:38)
The error object itself (of class ClassNotFoundException) only has the following stacktrace:
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.
And the message wrapped in this exception object only says: "nu.xom.Node"
Anyway, I'll try your workaround and I've found another one that would be working, too, though in the long run it might be a bit too broad: If I change my Eclipse debug setting by deselecting „Suspend execution on uncaught exceptions“, I can actually get actually get past this problem. (Another option would be to surround my XPathFactoryImpl instantiation with a try-catch-block and thus to turn it from an uncaught into a caught exception.)
RE: ClassNotFoundException in Saxon 10.5 PE's XPathFactoryImpl constructor when run in Eclipse debug mode - Added by Michael Kay over 3 years ago
RE: ClassNotFoundException in Saxon 10.5 PE's XPathFactoryImpl constructor when run in Eclipse debug mode - Added by Kai Weber over 3 years ago
Yes, that helps to circumvent unwanted breakpoints, thank you!
Please register to reply