Exception when creating views.

Hi all, 

I am taking my first stab at building a port object view using the illustrious JFreeChart and am running into  a snag that I imagine is due to my ignorance but I haven't been able to put my finger on the specific issue yet. Any advice?

Exception in thread "OutPortView-Updater-1" org.knime.core.node.util.InvocationTargetRuntimeException: Exception during execution in Event Dispatch Thread
    at org.knime.core.node.util.ViewUtils.invokeAndWaitInEDT(ViewUtils.java:177)
    at org.knime.core.node.workflow.OutPortView.updateInternal(OutPortView.java:238)
    at org.knime.core.node.workflow.OutPortView.access$1(OutPortView.java:237)
    at org.knime.core.node.workflow.OutPortView$3.run(OutPortView.java:220)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/jfree/util/PublicCloneable
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:327)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:402)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at io.landysh.inflor.java.core.views.ColumnStoreViewFactory.getRendererComponent(ColumnStoreViewFactory.java:40)
    at io.landysh.inflor.java.core.views.ColumnStoreViewFactory.createView(ColumnStoreViewFactory.java:23)
    at io.landysh.inflor.java.knime.portTypes.annotatedVectorStore.ColumnStorePortObject.getViews(ColumnStorePortObject.java:153)
    at org.knime.core.node.workflow.OutPortView$4.runWithContext(OutPortView.java:257)
    at org.knime.core.node.workflow.OutPortView$4.run(OutPortView.java:243)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.jfree.util.PublicCloneable cannot be found by io.landysh.inflor_0.1.0
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 33 more

 

Looks like the view can't find the JFreeChart classes. Are you providing a JFreeChart jar in your plugin or depending on someone else?

Cheers

Sam

Hi Sam, thanks for the hint. I have the jar in my plugin and it is added to my classpath.  Is there another step I am missing that you know of? Is it better to just use the plugin from KNIME with it?

Cheers,

Aaron

 

 

Update: Switching to Automated dependency management allowed the code to work but I guess in using this method I loose the ability to  control the updates to these libraries, is that correct?

Thanks again,

Aaron

> I have the jar in my plugin and it is added to my classpath.  Is there another step I am missing that you know of

I believe this is all you should need to do, but it may depend on how you've added it to the classpath. Did you add it under the Classpath area in the Runtime tab for your plugin.xml or add it to your java build path? I suspect doing the second option would allow you to use the classes in the development environment but not execute them when running in KNIME. 

(Just to check, did you add your JFreeChart lib to the bottom right area of the plugin.xml/Runtime?)

 

I'm trying to recall when I've had similar issues. I think it occurs when your development environment is providing you a different version to the executing version. If the JFreeChart library is KNIME is loaded first, and this doesn't provide the classes you've developed against then you will get exceptions (it also becomes interesting over which version gets loaded first). However, you can control which version of an OSGi plugin your plugin depends on. 

> Switching to Automated dependency management allowed the code to work but I guess in using this method I loose the ability to  control the updates to these libraries, is that correct? 

I've never used the automated management of depencies. I always add my dependencies are required plug ins or as jars by adding them to the classpath in the runtime tab. But it sounds like you are now using the KNIME OSGi bundle for JFreeChart. 

If you add jfreechart in the plugin.xml under Dependencies either as a required plugin (where you can control version) or imported packages (where you don't care who provides them) then unless you also provide that plugin you are right, you have no control over the updates to these. I assume the same is true for the atomated depency management. 

Cheers

Sam