How does Smooks handle classloading?

168 views
Skip to first unread message

Ulrich Schuster

unread,
Apr 2, 2022, 8:13:28 AM4/2/22
to Smooks Users
Dear Claude, dear list members

As I understand, Smooks targets Java 1.8, but should work also on newer releases. I am using the latest 2.0.0-RC1 in a pure Kotlin environment on JDK 17. Throughout the development, I did encounter classloader warnings over and again. Fiddling with dependencies, I was able to get several toy examples up and running. inside IntelliJ. but as soon standalone executable fat JARs crash with the following error:

2022-04-02T13:55:51.291+0200 WARN Not scanning classpath for ClassLoader 'jdk.internal.loader.ClassLoaders$AppClassLoader'.  ClassLoader must implement 'java.net.URLClassLoader'.
2022-04-02T13:55:51.507+0200 WARN Not scanning classpath for ClassLoader 'jdk.internal.loader.ClassLoaders$AppClassLoader'.  ClassLoader must implement 'java.net.URLClassLoader'.
2022-04-02T13:55:51.564+0200 ERROR Error initializing smooks: Error processing resource file '/system-interceptors.xml'.


This is exactly the same error @Nestor already observed on WSO2. As per Claude's answer in the related thread, cause might be some shadowing on the class path. The class loader warnings above to me indicate that there seems to be some problem with Smooks using some deprecated (since Java 9) classloader API. Maybe this is the roor cause, maybe not.
To dig deeper, it would be very helpful to have an overview about how, where, and why Smooks does its own classpath scanning and classloading; especially, where does Smooks not play by the book but uses tweaks that might cause the above problems?

Thanks very much for your help!
Uli

Ulrich Schuster

unread,
Apr 2, 2022, 9:49:44 AM4/2/22
to Smooks Users
Somme addition: 
Executing Smooks in a unit test works perfectly fine. It is executing the fat jar generated by the maven-assembly plugin that causes the above-listed error. I've tried several assembly options, including multi-release and adding default implementation and specification entries, but to no avail.

Do I need to use the shade plugin instead? If so, which packages should be renamed?

Ulrich Schuster

unread,
Apr 2, 2022, 10:35:27 AM4/2/22
to Smooks Users
Playing around with the maven-shade plugin yields the following warning, which might hint at the cause:

[WARNING] smooks-core-2.0.0-RC1.jar, smooks-dfdl-cartridge-1.0.0-RC1.jar, smooks-edi-cartridge-2.0.0-RC1.jar, smooks-edifact-cartridge-2.0.0-RC1.jar define 1 overlapping resource:
[WARNING]   - META-INF/services/org.smooks.api.delivery.ContentHandlerFactory


Might this be the source of the problem? How to avoid this clash?

Claude Mamo

unread,
Apr 6, 2022, 12:34:50 AM4/6/22
to smook...@googlegroups.com
To dig deeper, it would be very helpful to have an overview about how, where, and why Smooks does its own classpath scanning and classloading; especially, where does Smooks not play by the book but uses tweaks that might cause the above problems?

I'm not particular familiar with that part of the codebase but I believe that Smooks is scanning the classes to discover annotations. Did Nestor create a GitHub issue for this? I can't find it, but if you create an issue, we'd need a minimum reproducible running example.

Claude

--
You received this message because you are subscribed to the Google Groups "Smooks Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smooks-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smooks-user/b10e97d7-5595-4431-a43f-9b25d99eef4en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages