Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » SwingNode - ClassNotFoundException
SwingNode - ClassNotFoundException [message #1401910] Wed, 16 July 2014 08:39 Go to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
Hi all,

I'm trying to integrate a Swing component into my E4 FX application.

Therefore I have a certain Part class


import javafx.embed.swing.SwingNode;
import javafx.scene.layout.BorderPane;

import javax.annotation.PostConstruct;
import javax.swing.SwingUtilities;

import my.project.efx.swing.SwingPartJPanel;

public class SwingPart {

	@PostConstruct
	public void init(BorderPane pane) {
		
		SwingNode swingNode = new SwingNode();
		
		createSwingPart(swingNode);
		
		pane.setCenter(swingNode);
		
	}
	
	private void createSwingPart(final SwingNode swingNode) {
		SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            	swingNode.setContent(new SwingPartJPanel());        
            }          
        });
	}
}


However, when embedding this as a Part in my E4 application and running this on JDK8 with eclipse-SDK-4.4-win32-x86_64-efx-1.0.0-SNAPSHOT I get an exception

!ENTRY org.eclipse.e4.ui.workbench 4 0 2014-07-16 10:21:55.363
!MESSAGE Unable to create class 'my.project.efx.swing.SwingPart' from bundle '36'
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javafx/embed/swing/SwingNode
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:348)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)
...
Caused by: java.lang.NoClassDefFoundError: javafx/embed/swing/SwingNode
	at java.lang.Class.getDeclaredConstructors0(Native Method)
...
Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.SwingNode cannot be found by my.project.efx.app_1.0.0.qualifier
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:336)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:328)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 73 more


My plugin.xml says:
Bundle-RequiredExecutionEnvironment: JavaSE-1.8


Shouldn't javafx.embed.swing.SwingNode be found any time since it is part of the java runtime ?

Best Regards,
Danny

[Updated on: Wed, 16 July 2014 08:41]

Report message to a moderator

Re: SwingNode - ClassNotFoundException [message #1401914 is a reply to message #1401910] Wed, 16 July 2014 08:42 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5628
Registered: July 2009
Senior Member
Is javafx.embed.swing part of you package import?

Tom

On 16.07.14 10:39, Danny Tramnitzke wrote:
> Hi all,
>
> I'm trying to integrate a Swing component into my E4 FX application.
>
> Therefore I have a certain Part class
>
>
> import javafx.embed.swing.SwingNode;
> import javafx.scene.layout.BorderPane;
>
> import javax.annotation.PostConstruct;
> import javax.swing.SwingUtilities;
>
> import my.project.efx.swing.SwingPartJPanel;
>
> public class SwingPart {
>
> @PostConstruct
> public void init(BorderPane pane) {
>
> SwingNode swingNode = new SwingNode();
>
> createSwingPart(swingNode);
>
> pane.setCenter(swingNode);
>
> }
>
> private void createSwingPart(final SwingNode swingNode) {
> SwingUtilities.invokeLater(new Runnable() {
> @Override
> public void run() {
> swingNode.setContent(new SwingPartJPanel());
> } });
> }
> }
>
> However, when embedding this as a Part in my E4 application and running
> this on JDK8 with eclipse-SDK-4.4-win32-x86_64-efx-1.0.0-SNAPSHOT I get
> an exception
>
> !ENTRY org.eclipse.e4.ui.workbench 4 0 2014-07-16 10:21:55.363
> !MESSAGE Unable to create class 'my.project.efx.swing.SwingPart' from
> bundle '36'
> !STACK 0
> org.eclipse.e4.core.di.InjectionException:
> java.lang.NoClassDefFoundError: javafx/embed/swing/SwingNode
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:348)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:258)
> at
> org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
>
> at
> org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)
>
> ..
> Caused by: java.lang.NoClassDefFoundError: javafx/embed/swing/SwingNode
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> ..
> Caused by: java.lang.ClassNotFoundException:
> javafx.embed.swing.SwingNode cannot be found by
> my.project.efx.app_1.0.0.qualifier
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:336)
>
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:328)
>
> at
> org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 73 more
>
>
> Shouldn't javafx.embed.swing.SwingNode be found any time since it is
> part of the java runtime ?
>
> Best Regards,
> Danny
Re: SwingNode - ClassNotFoundException [message #1401971 is a reply to message #1401914] Wed, 16 July 2014 10:24 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
ah right, thanks !

Import-Package:
...,
javafx.embed.swing;version="2.0.0"
Re: SwingNode - ClassNotFoundException [message #1401974 is a reply to message #1401914] Wed, 16 July 2014 10:25 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
ah right, thanks!

Import-Package:
...,
javafx.embed.swing;version="2.0.0"
Re: SwingNode - ClassNotFoundException [message #1401975 is a reply to message #1401914] Wed, 16 July 2014 10:26 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
ah right, thanks!

Import-Package:
...,
javafx.embed.swing;version="2.0.0"
Re: SwingNode - ClassNotFoundException [message #1401994 is a reply to message #1401914] Wed, 16 July 2014 11:00 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
ok, thanks!
I added javafx.embed.swing to the Import-Package(s) in MANIFEST.MF

Now, my java.awt.Label is not displayed at the Swing-Part Sad
But it runs standanlone, though.

JFX-Part with Swing component
public class SwingPart {

	@PostConstruct
	public void init(BorderPane pane) {
		
		SwingNode swingNode = new SwingNode();
		
		createSwingPart(swingNode);
		
		pane.setCenter(swingNode);
		
	}
	
	private void createSwingPart(final SwingNode swingNode) {
		SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            	swingNode.setContent(new SwingPartPanel());        
            }          
        });
	}
}


Swing component
public class SwingPartPanel extends JPanel {

	private static final long serialVersionUID = -2529807437953504842L;

	public SwingPartPanel() {
		
		Label swingLabel = new Label("I'm a " + Label.class.getName());
		
		add(swingLabel);
	}
	
	public static void main(String[] args){
		
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				
				JFrame jframe = new JFrame();
				jframe.add(new SwingPartPanel(), BorderLayout.CENTER);
				
				// Display the window.
				jframe.pack();
				jframe.setSize(800, 800);
				jframe.setVisible(true);
			}
		});
	}
}
Re: SwingNode - ClassNotFoundException [message #1401995 is a reply to message #1401914] Wed, 16 July 2014 11:02 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
ok, thanks!
I added javafx.embed.swing to the Import-Package(s) in MANIFEST.MF

Now, my java.awt.Label is not displayed at the Swing-Part Sad
But it runs standanlone, though.

JFX-Part with Swing component
public class SwingPart {

	@PostConstruct
	public void init(BorderPane pane) {
		
		SwingNode swingNode = new SwingNode();
		
		createSwingPart(swingNode);
		
		pane.setCenter(swingNode);
		
	}
	
	private void createSwingPart(final SwingNode swingNode) {
		SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            	swingNode.setContent(new SwingPartPanel());        
            }          
        });
	}
}


Swing component
public class SwingPartPanel extends JPanel {

	private static final long serialVersionUID = -2529807437953504842L;

	public SwingPartPanel() {
		
		Label swingLabel = new Label("I'm a " + Label.class.getName());
		
		add(swingLabel);
	}
	
	public static void main(String[] args){
		
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				
				JFrame jframe = new JFrame();
				jframe.add(new SwingPartPanel(), BorderLayout.CENTER);
				
				// Display the window.
				jframe.pack();
				jframe.setSize(800, 800);
				jframe.setVisible(true);
			}
		});
	}
}
Re: SwingNode - ClassNotFoundException [message #1401998 is a reply to message #1401995] Wed, 16 July 2014 11:08 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5628
Registered: July 2009
Senior Member
I frankly don't know but what I know is that you can get rid of this
dirty threading stuff. Simply launch with
"-Djavafx.embed.singleThread=true" then FX & Swing run on the same event
thread!

Tom

On 16.07.14 13:02, Danny Tramnitzke wrote:
> ok, thanks!
> I added javafx.embed.swing to the Import-Package(s) in MANIFEST.MF
>
> Now, my java.awt.Label is not displayed at the Swing-Part :( But it runs
> standanlone, though.
>
> JFX-Part with Swing component
> public class SwingPart {
>
> @PostConstruct
> public void init(BorderPane pane) {
>
> SwingNode swingNode = new SwingNode();
>
> createSwingPart(swingNode);
>
> pane.setCenter(swingNode);
>
> }
>
> private void createSwingPart(final SwingNode swingNode) {
> SwingUtilities.invokeLater(new Runnable() {
> @Override
> public void run() {
> swingNode.setContent(new SwingPartPanel());
> } });
> }
> }
>
> Swing component
> public class SwingPartPanel extends JPanel {
>
> private static final long serialVersionUID = -2529807437953504842L;
>
> public SwingPartPanel() {
>
> Label swingLabel = new Label("I'm a " + Label.class.getName());
>
> add(swingLabel);
> }
>
> public static void main(String[] args){
>
> javax.swing.SwingUtilities.invokeLater(new Runnable() {
> public void run() {
>
> JFrame jframe = new JFrame();
> jframe.add(new SwingPartPanel(), BorderLayout.CENTER);
>
> // Display the window.
> jframe.pack();
> jframe.setSize(800, 800);
> jframe.setVisible(true);
> }
> });
> }
> }
Re: SwingNode - ClassNotFoundException [message #1402174 is a reply to message #1401998] Wed, 16 July 2014 16:34 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
Thomas Schindl wrote on Wed, 16 July 2014 07:08
I frankly don't know but what I know is that you can get rid of this
dirty threading stuff. Simply launch with
"-Djavafx.embed.singleThread=true" then FX & Swing run on the same event
thread!

Tom


Restricting to only one thread helps when resizing the application window. Now the Java-Fx Part does not resize slowly after the JFX container window.
But is has not effect on displaying the content of JPanel. My label is still missing.
The JPanel itself is being rendered, which I can see, when I change the background color of it.

setBackground(Color.CYAN);


PS: sorry for the duplicate posts before! I asked the webmaster of eclipse forums. There have been some technical problems this afternoon.
Re: SwingNode - ClassNotFoundException [message #1402264 is a reply to message #1402174] Wed, 16 July 2014 19:29 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5628
Registered: July 2009
Senior Member
Are you sure one can include AWT-Components? I just tried with JLabel &
JButton whereas AWT-Label/AWT-Button and they work but performance at
least on OS-X is unusable once the swingnode scaling, ... is useable
even on the latest 8u20 build!

Tom

On 16.07.14 18:34, Danny Tramnitzke wrote:
> Thomas Schindl wrote on Wed, 16 July 2014 07:08
>> I frankly don't know but what I know is that you can get rid of this
>> dirty threading stuff. Simply launch with
>> "-Djavafx.embed.singleThread=true" then FX & Swing run on the same event
>> thread!
>>
>> Tom
>
>
> Restricting to only one thread helps when resizing the application
> window. Now the Java-Fx Part does not resize slowly after the JFX
> container window. But is has not effect on displaying the content of
> JPanel. My label is still missing.
> The JPanel itself is being rendered, which I can see, when I change the
> background color of it.
>
>
> setBackground(Color.CYAN);
>
>
> PS: sorry for the duplicate posts before! I asked the webmaster of
> eclipse forums. There have been some technical problems this afternoon.
>
Re: SwingNode - ClassNotFoundException [message #1402646 is a reply to message #1402264] Thu, 17 July 2014 09:31 Go to previous messageGo to next message
Danny Tramnitzke is currently offline Danny TramnitzkeFriend
Messages: 15
Registered: April 2014
Junior Member
I see, at least JLabel works!

I want to integrade an old custom swing compontent in an efxclipse application.
It uses some AWT components itself. I will try to replace them with according Swing components.

Performance: I still have to check that
Re: SwingNode - ClassNotFoundException [message #1402803 is a reply to message #1402646] Thu, 17 July 2014 14:23 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5628
Registered: July 2009
Senior Member
All I can say SwingNode-Performance on OS-X is not OK at least on my
system but that is not a problem of efxclipse but I can reproduce the
same standalone app so the perf problem is not introduced by efxclipse.

Tom

On 17.07.14 11:31, Danny Tramnitzke wrote:
> I see, at least JLabel works!
>
> I want to integrade an old custom swing compontent in an efxclipse
> application.
> It uses some AWT components itself. I will try to replace them with
> according Swing components.
>
> Performance: I still have to check that
Previous Topic:Error Loading Hooks on Luna
Next Topic:Layout of MParts that are referenced by MPlaceholders
Goto Forum:
  


Current Time: Tue Mar 31 08:45:46 GMT 2015

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

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