Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Testing FXCanvas with SWTBot
Testing FXCanvas with SWTBot [message #1395801] Mon, 07 July 2014 12:19 Go to next message
Łukasz Drąg is currently offline Łukasz DrągFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,

I'm currently struggling with SWTBot test for a part based on FXCanvas. If in my test method I try to open this part with:
EPartService.showPart( "foo.bar.myFXCanvasPart", PartState.ACTIVATE );


I always end up with:
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Canvas
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:62)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:888)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:120)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
....
Caused by: java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Canvas
	at java.lang.ClassLoader.findBootstrapClass(Native Method)
	at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1012)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:413)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.eclipse.fx.osgi.fxloader.FXClassLoader$FXModuleClassloader$1.findLocalClass(FXClassLoader.java:140)


The test run configuration contains the necessary OSGi extension:
-Dosgi.framework.extensions=org.eclipse.fx.osgi

The interesting thing is that when I start the application (not a test case) everything is just fine, the fx-based part works without any problems.

Does anybody have a clue what's wrong?
Re: Testing FXCanvas with SWTBot [message #1395820 is a reply to message #1395801] Mon, 07 July 2014 12:49 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
Try adding "-Defxclipse.osgi.hook.debug=true" this should give you more
informations about the hook classloading.

Tom

On 07.07.14 14:19, Łukasz Drąg wrote:
> Hi,
>
> I'm currently struggling with SWTBot test for a part based on FXCanvas.
> If in my test method I try to open this part with:
>
> EPartService.showPart( "foo.bar.myFXCanvasPart", PartState.ACTIVATE );
>
>
> I always end up with:
>
> org.eclipse.e4.core.di.InjectionException:
> java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Canvas
> at
> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:62)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:888)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:120)
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:337)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
> ...
> Caused by: java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Canvas
> at java.lang.ClassLoader.findBootstrapClass(Native Method)
> at
> java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1012)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:413)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at
> org.eclipse.fx.osgi.fxloader.FXClassLoader$FXModuleClassloader$1.findLocalClass(FXClassLoader.java:140)
>
>
> The test run configuration contains the necessary OSGi extension:
> -Dosgi.framework.extensions=org.eclipse.fx.osgi
>
> The interesting thing is that when I start the application (not a test
> case) everything is just fine, the fx-based part works without any
> problems.
>
> Does anybody have a clue what's wrong?
Re: Testing FXCanvas with SWTBot [message #1396311 is a reply to message #1395820] Tue, 08 July 2014 05:57 Go to previous messageGo to next message
Łukasz Drąg is currently offline Łukasz DrągFriend
Messages: 10
Registered: July 2009
Junior Member
I already did that, but without much effect. The result output looks like this:
FXClassLoader#createJREBundledClassloader - Started
FXClassLoader#createJREBundledClassloader - Assumed location (Java 8/Java 7): C:\Program Files\Java\jdk1.8.0_05\jre\lib\ext\jfxrt.jar
FXClassLoader#createJREBundledClassloader - SWT is available use different loading strategy
FXClassLoader#createJREBundledClassloader - Searching for SWT-FX integration at C:\Program Files\Java\jdk1.8.0_05\jre\lib\jfxswt.jar
FXClassLoader#createJREBundledClassloader - Found SWT/FX
FXClassLoader#createJREBundledClassloader - Delegate to system classloader
FXClassLoader#createJREBundledClassloader - Ended
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.ObservableList'
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.transformation.FilteredList'
FXModuleClassloader#findLocalClass trying to load class 'com.sun.javafx.collections.ObservableSequentialListWrapper'
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.ListChangeListener'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.Control'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.ListCell'
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.ListChangeListener$Change'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.input.DragEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.canvas.Canvas'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.input.MouseEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.ContextMenu'
FXModuleClassloader#findLocalClass trying to load class 'javafx.event.ActionEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.beans.Observable'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Parent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.layout.BorderPane'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Node'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.layout.HBox'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.ToolBar'
FXModuleClassloader#findLocalClass trying to load class 'javafx.embed.swt.FXCanvas'
FXModuleClassloader#findLocalClass - Someone is trying to load FXCanvas. Need to check for GTK3
FXModuleClassloader#findLocalClass trying to load class 'org.eclipse.swt.SWT'
FXModuleClassloader#findLocalClass - OS is 'win32' no need to get upset all is fine
FXModuleClassloader#findLocalClass - We need to disable implicit exiting when running in embedded mode
FXModuleClassloader#findLocalClass trying to load class 'javafx.application.Platform'

At this point the hook debug output ends as the mentioned NoClassDefFoundError appears.

The debug of class loading with -verbose:class switch says clearly that the problematic class is being loaded:
...[Loaded org.eclipse.swt.widgets.Canvas from file:/C:/.../.metadata/.plugins/org.eclipse.pde.core/.bundle_pool/plugins/org.eclipse.swt.win32.win32.x86_64_3.103.0.v20140605-2012.jar]

...
[/code]

I've also tried to follow the suggestions to put the swt jar into the boot classpath but with no success.


Łukasz
Re: Testing FXCanvas with SWTBot [message #1396415 is a reply to message #1396311] Tue, 08 July 2014 09:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
I've checked in a few modifications
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=439110) and bit more
detailed logging what classloaders are used so now I get:


> FXClassLoader#createJREBundledClassloader - Started
> FXClassLoader#createJREBundledClassloader - Assumed location (Java 8/Java 7): /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/ext/jfxrt.jar
> FXClassLoader#createJREBundledClassloader - SWT is available use different loading strategy
> FXClassLoader#createJREBundledClassloader - Searching for SWT-FX integration at /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre/lib/jfxswt.jar
> FXClassLoader#createJREBundledClassloader - Found SWT/FX
> FXClassLoader#createJREBundledClassloader - Delegate to system classloader
> FXClassLoader.SWTFXClassloader#init - Primary Loader sun.misc.Launcher$ExtClassLoader@3b81a1bc
> FXClassLoader.SWTFXClassloader#init - Lastresort Loader org.eclipse.osgi.internal.loader.EquinoxClassLoader@4a23350[org.eclipse.swt:3.103.0.v20140522-1609(id=389)]
> FXClassLoader#createJREBundledClassloader - Ended
> FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Parent'
> FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.layout.BorderPane'
> FXModuleClassloader#findLocalClass trying to load class 'javafx.embed.swing.JFXPanel'
> FXModuleClassloader#findLocalClass trying to load class 'javafx.embed.swt.FXCanvas'
> FXModuleClassloader#findLocalClass - Someone is trying to load FXCanvas. Need to check for GTK3
> FXModuleClassloader#findLocalClass trying to load class 'org.eclipse.swt.SWT'
> FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.SWT with primary
> FXClassLoader.SWTFXClassloader#findClass - ClassNotFoundException thrown
> FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.SWT with last resort
> FXClassLoader.SWTFXClassloader#findClass - Result org.eclipse.swt.SWT class org.eclipse.swt.SWT
> FXModuleClassloader#findLocalClass - OS is 'cocoa' no need to get upset all is fine
> FXModuleClassloader#findLocalClass - We need to disable implicit exiting when running in embedded mode
> FXModuleClassloader#findLocalClass trying to load class 'javafx.application.Platform'
> FXClassLoader.SWTFXClassloader#findClass - Loading javafx.embed.swt.FXCanvas with primary
> FXClassLoader.SWTFXClassloader#findClass - ClassNotFoundException thrown
> FXClassLoader.SWTFXClassloader#findClass - Loading javafx.embed.swt.FXCanvas with last resort
> FXClassLoader.SWTFXClassloader#findClass - Even last resort was unable to load javafx.embed.swt.FXCanvas
> FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.widgets.Canvas with primary
> FXClassLoader.SWTFXClassloader#findClass - ClassNotFoundException thrown
> FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.widgets.Canvas with last resort
> FXClassLoader.SWTFXClassloader#findClass - Result org.eclipse.swt.widgets.Canvas class org.eclipse.swt.widgets.Canvas

Notice the information about:
a) the used classloaders
b) the information that we are delegating from the primary to the last
resort loader

A new build has been published so if you reload your target platform you
should get a more detailed output.

Tom
Re: Testing FXCanvas with SWTBot [message #1398088 is a reply to message #1396415] Thu, 10 July 2014 15:41 Go to previous messageGo to next message
Łukasz Drąg is currently offline Łukasz DrągFriend
Messages: 10
Registered: July 2009
Junior Member
Thank you for providing the classloader info.

The output I get now looks like this:

FXClassLoader#createJREBundledClassloader - Started
FXClassLoader#createJREBundledClassloader - Assumed location (Java 8/Java 7): C:\Program Files\Java\jdk1.8.0_05\jre\lib\ext\jfxrt.jar
FXClassLoader#createJREBundledClassloader - SWT is available use different loading strategy
FXClassLoader#createJREBundledClassloader - Searching for SWT-FX integration at C:\Program Files\Java\jdk1.8.0_05\jre\lib\jfxswt.jar
FXClassLoader#createJREBundledClassloader - Found SWT/FX
FXClassLoader#createJREBundledClassloader - Delegate to system classloader
FXClassLoader.SWTFXClassloader#init - Primary Loader sun.misc.Launcher$ExtClassLoader@1d9bd4da
FXClassLoader.SWTFXClassloader#init - Lastresort Loader org.eclipse.osgi.internal.loader.EquinoxClassLoader@107e5441[org.eclipse.swt:3.103.0.v20140605-2008(id=71)]
FXClassLoader#createJREBundledClassloader - Ended
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.ObservableList'
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.transformation.FilteredList'
FXModuleClassloader#findLocalClass trying to load class 'com.sun.javafx.collections.ObservableSequentialListWrapper'
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.ListChangeListener'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.Control'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.ListCell'
FXModuleClassloader#findLocalClass trying to load class 'javafx.collections.ListChangeListener$Change'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.input.InputEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.canvas.Canvas'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.input.DragEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.input.MouseEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.ContextMenu'
FXModuleClassloader#findLocalClass trying to load class 'javafx.event.ActionEvent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.beans.Observable'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Parent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.layout.BorderPane'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Node'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.layout.HBox'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.control.ToolBar'
FXModuleClassloader#findLocalClass trying to load class 'javafx.embed.swt.FXCanvas'
FXModuleClassloader#findLocalClass - Someone is trying to load FXCanvas. Need to check for GTK3
FXModuleClassloader#findLocalClass trying to load class 'org.eclipse.swt.SWT'
FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.SWT with primary
FXClassLoader.SWTFXClassloader#findClass - ClassNotFoundException thrown
FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.SWT with last resort
FXClassLoader.SWTFXClassloader#findClass - Result org.eclipse.swt.SWT class org.eclipse.swt.SWT
FXModuleClassloader#findLocalClass - OS is 'win32' no need to get upset all is fine
FXModuleClassloader#findLocalClass - We need to disable implicit exiting when running in embedded mode
FXModuleClassloader#findLocalClass trying to load class 'javafx.application.Platform'


Would you have any hint for me?
Re: Testing FXCanvas with SWTBot [message #1398224 is a reply to message #1398088] Thu, 10 July 2014 20:22 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5673
Registered: July 2009
Senior Member
Not really that looks just fine!

Tom

On 10.07.14 17:41, Łukasz Drąg wrote:
> Thank you for providing the classloader info.
>
> The output I get now looks like this:
>
> FXClassLoader#createJREBundledClassloader - Started
> FXClassLoader#createJREBundledClassloader - Assumed location (Java
> 8/Java 7): C:\Program Files\Java\jdk1.8.0_05\jre\lib\ext\jfxrt.jar
> FXClassLoader#createJREBundledClassloader - SWT is available use
> different loading strategy
> FXClassLoader#createJREBundledClassloader - Searching for SWT-FX
> integration at C:\Program Files\Java\jdk1.8.0_05\jre\lib\jfxswt.jar
> FXClassLoader#createJREBundledClassloader - Found SWT/FX
> FXClassLoader#createJREBundledClassloader - Delegate to system classloader
> FXClassLoader.SWTFXClassloader#init - Primary Loader
> sun.misc.Launcher$ExtClassLoader@1d9bd4da
> FXClassLoader.SWTFXClassloader#init - Lastresort Loader
> org.eclipse.osgi.internal.loader.EquinoxClassLoader@107e5441[org.eclipse.swt:3.103.0.v20140605-2008(id=71)]
>
> FXClassLoader#createJREBundledClassloader - Ended
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.collections.ObservableList'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.collections.transformation.FilteredList'
> FXModuleClassloader#findLocalClass trying to load class
> 'com.sun.javafx.collections.ObservableSequentialListWrapper'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.collections.ListChangeListener'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.control.Control'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.control.ListCell'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.collections.ListChangeListener$Change'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.input.InputEvent'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.canvas.Canvas'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.input.DragEvent'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.input.MouseEvent'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.control.ContextMenu'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.event.ActionEvent'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.beans.Observable'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.Parent'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.layout.BorderPane'
> FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Node'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.layout.HBox'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.scene.control.ToolBar'
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.embed.swt.FXCanvas'
> FXModuleClassloader#findLocalClass - Someone is trying to load FXCanvas.
> Need to check for GTK3
> FXModuleClassloader#findLocalClass trying to load class
> 'org.eclipse.swt.SWT'
> FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.SWT
> with primary
> FXClassLoader.SWTFXClassloader#findClass - ClassNotFoundException thrown
> FXClassLoader.SWTFXClassloader#findClass - Loading org.eclipse.swt.SWT
> with last resort
> FXClassLoader.SWTFXClassloader#findClass - Result org.eclipse.swt.SWT
> class org.eclipse.swt.SWT
> FXModuleClassloader#findLocalClass - OS is 'win32' no need to get upset
> all is fine
> FXModuleClassloader#findLocalClass - We need to disable implicit exiting
> when running in embedded mode
> FXModuleClassloader#findLocalClass trying to load class
> 'javafx.application.Platform'
>
> Would you have any hint for me?
Previous Topic:e(fx)clipse 1.0-SNAPSHOT - Sample App Errors
Next Topic:About Library packaging
Goto Forum:
  


Current Time: Sat Apr 25 06:57:29 GMT 2015

Powered by FUDForum. Page generated in 0.02138 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software