Project

Profile

Help

Bug #6024

closed

java.lang.NoClassDefFoundError: org/jdom2/Document

Added by Johan Gheys 10 months ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
Start date:
2023-05-09
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
Java

Description

We are running tests to switch from Saxon-EE 11.5 to 12.2. When starting a transformation via the command line, we now get the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom2/Document
	at net.sf.saxon.option.jdom2.JDOM2ObjectModel.isRecognizedNodeClass(JDOM2ObjectModel.java:159)
	at net.sf.saxon.option.jdom2.JDOM2ObjectModel.getJPConverter(JDOM2ObjectModel.java:118)
	at net.sf.saxon.expr.JPConverter.allocate(JPConverter.java:207)
	at com.saxonica.expr.JavaExtensionFunctionCall.typeCheck(JavaExtensionFunctionCall.java:256)
	at net.sf.saxon.style.StyleElement.typeCheck(StyleElement.java:1556)
	at net.sf.saxon.style.XSLSequence.validate(XSLSequence.java:94)
	at net.sf.saxon.style.StyleElement.validateSubtree(StyleElement.java:1736)
	at net.sf.saxon.style.StyleElement.validateChildren(StyleElement.java:1769)
	at net.sf.saxon.style.StyleElement.validateSubtree(StyleElement.java:1740)
	at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(PrincipalStylesheetModule.java:398)
	at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:290)
	at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:254)
	at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:113)
	at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:971)
	at net.sf.saxon.Transform.doTransform(Transform.java:777)
	at net.sf.saxon.Transform.main(Transform.java:83)
Caused by: java.lang.ClassNotFoundException: org.jdom2.Document
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 16 more

whereas with version 11.5 this went smoothly. Does something need to be adjusted or have we overlooked something?


Files

command-line-6024.zip (1.95 KB) command-line-6024.zip Johan Gheys, 2023-05-09 12:10
Actions #1

Updated by Martin Honnen 10 months ago

Sounds a bit like https://saxonica.plan.io/issues/5920 but that is supposed to have been fixed in 12.1., I think

Actions #2

Updated by Johan Gheys 10 months ago

Added a simple test case. Importing a stylesheet with references to java classes apparently still causes problems in 12.2.

Actions #3

Updated by Norm Tovey-Walsh 10 months ago

Bug #6024: java.lang.NoClassDefFoundError: org/jdom2/Document open

  • Author: Johan Gheys
  • Status: New
  • Priority: Normal
  • Sprint/Milestone: 12.2
  • Start date: 2023-05-09

We are running tests to switch from Saxon-EE 11.5 to 12.2. When starting a transformation via
the command line, we now get the following error message:

I hope this isn’t a silly question, but are you sure the JDOM2 classes
are on your classpath? They aren’t shipped as part of Saxon.

Be seeing you,
norm

--
Norm Tovey-Walsh
Saxonica

Actions #4

Updated by Johan Gheys 10 months ago

No, the JDOM2 classes are not on the classpath (see attached files) because we don't want to use them. As the documentation states: "To use SaxonJ with DOM, you do not need any extra code on your classpath". This worked correctly in 11.5.

Actions #5

Updated by Norm Tovey-Walsh 10 months ago

Sorry. I misunderstood the context. I agree, it does look like #5920 resurfacing.

Actions #6

Updated by Michael Kay 10 months ago

It seems that the fix for #5920 added catch (Exception e) in a couple of places. However, java.lang.NoClassDefFoundError is not an Exception (it's an Error), so it isn't being caught.

It feels like the fix is to catch Throwable. The real problem here is testing; we don't have a good mechanism for running tests with a non-standard classpath.

Actions #7

Updated by Michael Kay 10 months ago

  • Category set to Saxon extensions
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Applies to branch 12, trunk added
  • Fix Committed on Branch 12, trunk added
  • Platforms Java added

I revised the patch to catch Throwable, did a new build, and ran the test from the command line without any JDOM/DOM4J etc classes on the classpath and it ran correctly.

Actions #8

Updated by Johan Gheys 10 months ago

Every time, we are impressed by your speed of intervention! Thank you Michael.

Actions #9

Updated by Norm Tovey-Walsh 10 months ago

I'll create a build/release task to configure tests with a different classpath. That's not too hard to do.

Actions #10

Updated by O'Neil Delpratt 8 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 12.3 added

Bug fix applied in the Saxon 12.3 maintenance release.

Please register to edit this issue

Also available in: Atom PDF