Hi,
as there are security issues, I was looking for a solution to get rid of my xstream dependency. I played around with the Jakarta XML binding library. In the KNIME target platform is the plugin jakarta.xml.bind available as version 2.3.3.
But I get ClassNotFoundException during runtime.
This is the piece of code and the error it throws:
WARN main WrappedNodeDialog failed to apply settings: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
org.knime.core.node.InvalidSettingsException: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
at de.mpicbg.knime.scripting.core.ScriptingNodeDialog.saveAdditionalSettingsTo(ScriptingNodeDialog.java:462)
at org.knime.core.node.defaultnodesettings.DefaultNodeSettingsPane.saveSettingsTo(DefaultNodeSettingsPane.java:293)
at org.knime.core.node.NodeDialogPane.internalSaveSettingsTo(NodeDialogPane.java:540)
at org.knime.core.node.NodeDialogPane$4.run(NodeDialogPane.java:779)
at org.knime.core.node.util.ViewUtils$3.run(ViewUtils.java:353)
at org.knime.core.node.util.ViewUtils$2.run(ViewUtils.java:155)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:255)
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:243)
at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:407)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:632)
at de.mpicbg.knime.scripting.core.rgg.wizard.ScriptTemplate.toXML(ScriptTemplate.java:178)
at de.mpicbg.knime.scripting.core.ScriptingNodeDialog.saveAdditionalSettingsTo(ScriptingNodeDialog.java:460)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:147)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at jakarta.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:92)
at jakarta.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:125)
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:253)
... 24 more
Then, I tried to make use of the library (version 3.0.1) via my plugin libraries. I tried to download dependencies but failed.
I was wondering whether I can get a helpful hint here how to get things working. Maybe there are already experiences. I can also use a different library. I just need some way to serialize a class as XML.
These kinds of JAXBContext initialization is a bit tricky in OSGi. You need to set the context classloader to be the same as one of the classes from your plugin.
WARN main WrappedNodeDialog failed to apply settings: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory cannot be found by de.mpicbg.knime.scripting.core_4.2.0.qualifier]
org.knime.core.node.InvalidSettingsException: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory cannot be found by de.mpicbg.knime.scripting.core_4.2.0.qualifier]
at de.mpicbg.knime.scripting.core.ScriptingNodeDialog.saveAdditionalSettingsTo(ScriptingNodeDialog.java:462)
at org.knime.core.node.defaultnodesettings.DefaultNodeSettingsPane.saveSettingsTo(DefaultNodeSettingsPane.java:293)
at org.knime.core.node.NodeDialogPane.internalSaveSettingsTo(NodeDialogPane.java:540)
at org.knime.core.node.NodeDialogPane$4.run(NodeDialogPane.java:779)
at org.knime.core.node.util.ViewUtils$3.run(ViewUtils.java:353)
at org.knime.core.node.util.ViewUtils$2.run(ViewUtils.java:155)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory cannot be found by de.mpicbg.knime.scripting.core_4.2.0.qualifier]
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:255)
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:243)
at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:407)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:632)
at de.mpicbg.knime.scripting.core.rgg.wizard.ScriptTemplate.toXML(ScriptTemplate.java:178)
at de.mpicbg.knime.scripting.core.ScriptingNodeDialog.saveAdditionalSettingsTo(ScriptingNodeDialog.java:460)
... 18 more
Caused by: java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory cannot be found by de.mpicbg.knime.scripting.core_4.2.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:541)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:536)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at jakarta.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:92)
at jakarta.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:125)
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:253)
... 24 more