itemis / gef-mindmap-tutorial

GEF Mindmap Tutorial
GNU General Public License v3.0
9 stars 4 forks source link

Error with executing MindMapVisualApplication in Part 1 of Tutorial. #3

Open SiriusCyrus opened 3 years ago

SiriusCyrus commented 3 years ago

Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/SetMultimap at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:760) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.eclipse.gef.fx.nodes.Connection.(Connection.java:277) at com.itemis.gef.tutorial.mindmap.visuals.MindMapConnectionVisual.(MindMapConnectionVisual.java:17) at com.itemis.gef.tutorial.mindmap.visuals.MindMapVisualApplication.start(MindMapVisualApplication.java:37) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) ... 1 more Caused by: java.lang.ClassNotFoundException: com.google.common.collect.SetMultimap at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 24 more Exception running application com.itemis.gef.tutorial.mindmap.visuals.MindMapVisualApplication

The above stack trace result is generated after executing every single step of Part 1 of the tutorial provided on the website. I did a complete code coverage and the error seems to generate from the part of the code in "MindMapVisualApplication"

**Connection conn = new MindMapConnectionVisual(); conn.setStartAnchor(new DynamicAnchor(node, new ChopBoxStrategy())); conn.setEndAnchor(new DynamicAnchor(node2, new ChopBoxStrategy()));

    root.getChildren().addAll(conn, node, node2);

    primaryStage.setResizable(true);
    primaryStage.setScene(new Scene(root, 1024, 768));
    primaryStage.setTitle("This is an JavaFX Environment Test");
    primaryStage.sizeToScene();
    primaryStage.show();**

and also the whole "MindMapConnectionVisual" class.

I am running the on Eclipse IDE - 2018.12 with JavaSE 1.8 and Javafx-sdk-11.0.2

Would appreciate if anyone can provide me with a solution to this error.

miklossy commented 3 years ago

It seems to be a configuration problem in your development environment.

Could you please verify whether you set up your environment properly?

You can use the following blog post as a starting point: https://blogs.itemis.com/en/after-eight-eclipse-development-with-java-and-javafx

SiriusCyrus commented 3 years ago

Hi,

I tried the configuration mentioned in the blog, and it works. Unfortunately, I got the same error in Part 2, while creating the "SimpleMindMapApplication". I am following the tutorial and this was the error output. Could you guide me for a workaround for this issue?

java.lang.NullPointerException at com.itemis.gef.tutorial.mindmap.parts.MindMapNodePart.doRefreshVisual(MindMapNodePart.java:54) at com.itemis.gef.tutorial.mindmap.parts.MindMapNodePart.doRefreshVisual(MindMapNodePart.java:1) at org.eclipse.gef.mvc.fx.parts.AbstractVisualPart.refreshVisual(AbstractVisualPart.java:657) at org.eclipse.gef.mvc.fx.parts.AbstractVisualPart.addChildren(AbstractVisualPart.java:207) at org.eclipse.gef.mvc.fx.behaviors.ContentBehavior.lambda$1(ContentBehavior.java:501) at java.lang.Iterable.forEach(Iterable.java:75) at org.eclipse.gef.mvc.fx.behaviors.ContentBehavior.synchronizeContentPartChildren(ContentBehavior.java:498) at org.eclipse.gef.mvc.fx.behaviors.ContentBehavior$1.onChanged(ContentBehavior.java:93) at org.eclipse.gef.common.collections.ListListenerHelperEx.notifyListChangeListeners(ListListenerHelperEx.java:650) at org.eclipse.gef.common.collections.ListListenerHelperEx.fireValueChangedEvent(ListListenerHelperEx.java:600) at org.eclipse.gef.common.collections.ObservableListWrapperEx.setAll(ObservableListWrapperEx.java:355) at org.eclipse.gef.common.collections.ObservableListWrapperEx.setAll(ObservableListWrapperEx.java:367) at com.itemis.gef.tutorial.mindmap.SimpleMindMapApplication.populateViewerContents(SimpleMindMapApplication.java:58) at com.itemis.gef.tutorial.mindmap.SimpleMindMapApplication.start(SimpleMindMapApplication.java:79) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) at java.lang.Thread.run(Thread.java:745) Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at com.itemis.gef.tutorial.mindmap.parts.MindMapNodePart.doRefreshVisual(MindMapNodePart.java:54) at com.itemis.gef.tutorial.mindmap.parts.MindMapNodePart.doRefreshVisual(MindMapNodePart.java:1) at org.eclipse.gef.mvc.fx.parts.AbstractVisualPart.refreshVisual(AbstractVisualPart.java:657) at org.eclipse.gef.mvc.fx.parts.AbstractVisualPart.addChildren(AbstractVisualPart.java:207) at org.eclipse.gef.mvc.fx.behaviors.ContentBehavior.lambda$1(ContentBehavior.java:501) at java.lang.Iterable.forEach(Iterable.java:75) at org.eclipse.gef.mvc.fx.behaviors.ContentBehavior.synchronizeContentPartChildren(ContentBehavior.java:498) at org.eclipse.gef.mvc.fx.behaviors.ContentBehavior$1.onChanged(ContentBehavior.java:93) at org.eclipse.gef.common.collections.ListListenerHelperEx.notifyListChangeListeners(ListListenerHelperEx.java:650) at org.eclipse.gef.common.collections.ListListenerHelperEx.fireValueChangedEvent(ListListenerHelperEx.java:600) at org.eclipse.gef.common.collections.ObservableListWrapperEx.setAll(ObservableListWrapperEx.java:355) at org.eclipse.gef.common.collections.ObservableListWrapperEx.setAll(ObservableListWrapperEx.java:367) at com.itemis.gef.tutorial.mindmap.SimpleMindMapApplication.populateViewerContents(SimpleMindMapApplication.java:58) at com.itemis.gef.tutorial.mindmap.SimpleMindMapApplication.start(SimpleMindMapApplication.java:79) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) ... 1 more Exception running application com.itemis.gef.tutorial.mindmap.SimpleMindMapApplication

miklossy commented 3 years ago

How does the code line looks like throwing the NPE?

You can try to surround that code line by an if statement to control that the code is executed only if the certain object is not null.

hannesN commented 3 years ago

The solution is a null check before calling visual.getParent(), because it might be null in the initial startup.