FXCanvas not found during plugin export. [message #1622950] |
Wed, 18 February 2015 16:16  |
Eclipse User |
|
|
|
Hello,
I'm writting very simple plugin using Java 8 and JavaFX (some menu and opening window after some action on this menu). When I'm running this plugin from inside Eclipse (running second instance) to check it, everything goes fine. Unfotunately when I'm trying to export this plugin, I'm getting error with info that "import javafx.embed.swt.FXCanvas cannot be resolved".
I've found in some old discussion on this forum, that there is some very ugly solution and it relies on adding jfxrt.jar and jfxswt.jar to the project and to classpath. After such operation I could export whole plugin and install it in other Eclipse. Unfortunately plugin is not working corectly. My "item" in menu appears, but when I'm trying to launch action by clicking on it, nothing happens (there is JavaFX used in this action). No error, no excepion in command line.... nothing. When I'm writting the same thing using SWT, everything works fine.
What could be a reason of such behavior ? Maybe there is some more elegant way to resolve FXCanvas import (jfswt.jar is JRE library... so maybe there is no need to include it to plugin).
I'll be appreciate for help.
[Updated on: Thu, 19 February 2015 04:30] by Moderator
|
|
|
|
|
|
|
|
|
|
|
Re: FXCanvas not found during plugin export. [message #1647859 is a reply to message #1647171] |
Tue, 03 March 2015 11:47   |
Eclipse User |
|
|
|
Thanks for reply. Your answers are really useful.
Thomas Schindl wrote on Tue, 03 March 2015 09:36On 03.03.15 00:12, Piotr Iksowski wrote:
> Ok. So I've downloaded E(fx)clipse and I checked two simple plugins:
>
> 1. Exactly the same plugin as I described in the post. Some "Sample
> menu" that is opening JavaFX window. Behaviour is exactly the same as
> for simple Eclipse with FX plugin. If I don't add jfxrt.jar and
> jfxswt.jar, I won't be able to export it (FXCanvas not recognized when
> exporting).
This is because jfxswt.jar is not on the classpath so:
a) use maven to build your plugin
b) modify the build.properties to point to the jfxswt.jar
c) copy jfxswt.jar to the ext-folder of the jdk/jre used to build
I would strongly advice to use a) because this is also how you will
build the stuff on hudson/jenkins/.... .
Ok, seems it's working. I thought that jfxswt.jat is in classpath by default in Java 8.
Thomas Schindl wrote on Tue, 03 March 2015 09:36On 03.03.15 00:12, Piotr Iksowski wrote:
>
> 2. Plugin from https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial2
> I followed each step as in tutorial. Everything works fine if I'm
> running it from Eclipse. When I'm exporting it to "dropins" and
> restarting IDE nothing happens. Plugin seems to be not installed, no
> error or exceptions is thrown on console where eclipse is run. (even
> with -Defxclipse.osgi.hook.debug=true in eclipse.ini file and setting
> SWT_GTGK3 to 0)
> ..............................
>
> Is there any example(tutorial) how to write, export and install plugin
> which is using JavaFX in Eclipse ? 
The reason for that is most likely that your bundle did not resolve
because you have NOT deployed org.eclipse.fx.ui.workbench3 hence your
bundle does not resolve.
You can check the state of the bundle by:
* select the console view
* open the drop down in the far right
* select Host OSGi Console
* enter "ss org.eclipse.fx.ui.workbench3"
=> the first value in the list is the bundleId which you need in the
next step
* diag $BUNDLE_ID
Tom
It seems that org.eclipse.fx.ui.workbench3 is lacking:
osgi> ss org.eclipse.fx.ui.workbench3
"Framework is launched."
id State Bundle
osgi>
Is there any way to include org.eclipse.fx.ui.workbench3 into Target platform of the environment without using Tycho (or maven) ? Maybe there is a way to deploy it somehow with the plugin ?
I'm searching some simple solution for that, but I'm a little afraid that without getting acknowledge with Tycho, I won't resolve this and many other problems :/
|
|
|
Re: FXCanvas not found during plugin export. [message #1648066 is a reply to message #1647859] |
Tue, 03 March 2015 14:04   |
Eclipse User |
|
|
|
On 03.03.15 17:47, Piotr Iksowski wrote:
> Thanks for reply. Your answers are really useful.
>
> Thomas Schindl wrote on Tue, 03 March 2015 09:36
>> On 03.03.15 00:12, Piotr Iksowski wrote:
>> > Ok. So I've downloaded E(fx)clipse and I checked two simple plugins:
>> > > 1. Exactly the same plugin as I described in the post. Some "Sample
>> > menu" that is opening JavaFX window. Behaviour is exactly the same as
>> > for simple Eclipse with FX plugin. If I don't add jfxrt.jar and
>> > jfxswt.jar, I won't be able to export it (FXCanvas not recognized when
>> > exporting).
>>
>> This is because jfxswt.jar is not on the classpath so:
>> a) use maven to build your plugin
>> b) modify the build.properties to point to the jfxswt.jar
>> c) copy jfxswt.jar to the ext-folder of the jdk/jre used to build
>>
>> I would strongly advice to use a) because this is also how you will
>> build the stuff on hudson/jenkins/.... .
>
>
> Ok, seems it's working. I thought that jfxswt.jat is in classpath by
> default in Java 8.
jfxrt.jar is on the ext-classpath and i'm thankful that jfxswt.jar -
jfxswt.jar requires classes from swt! So if they would have put that on
the classpath this would have been a nightmare!
>
> Thomas Schindl wrote on Tue, 03 March 2015 09:36
>> On 03.03.15 00:12, Piotr Iksowski wrote:
>> > > 2. Plugin from https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial2
>> > I followed each step as in tutorial. Everything works fine if I'm
>> > running it from Eclipse. When I'm exporting it to "dropins" and
>> > restarting IDE nothing happens. Plugin seems to be not installed, no
>> > error or exceptions is thrown on console where eclipse is run. (even
>> > with -Defxclipse.osgi.hook.debug=true in eclipse.ini file and setting
>> > SWT_GTGK3 to 0)
>> > ..............................
>> > > Is there any example(tutorial) how to write, export and install
>> plugin
>> > which is using JavaFX in Eclipse ? :)
>>
>> The reason for that is most likely that your bundle did not resolve
>> because you have NOT deployed org.eclipse.fx.ui.workbench3 hence your
>> bundle does not resolve.
>>
>> You can check the state of the bundle by:
>> * select the console view
>> * open the drop down in the far right
>> * select Host OSGi Console
>> * enter "ss org.eclipse.fx.ui.workbench3"
>> => the first value in the list is the bundleId which you need in the
>> next step
>> * diag $BUNDLE_ID
>>
>> Tom
>
>
> It seems that org.eclipse.fx.ui.workbench3 is lacking:
> osgi> ss org.eclipse.fx.ui.workbench3
> "Framework is launched."
>
> id State Bundle
> osgi>
> Is there any way to include org.eclipse.fx.ui.workbench3 into Target
> platform of the environment without using Tycho (or maven) ? Maybe there
> is a way to deploy it somehow with the plugin ?
>
> I'm searching some simple solution for that, but I'm a little afraid
> that without getting acknowledge with Tycho, I won't resolve this and
> many other problems :/
If you are doing Eclipse plug-in dev at least semi professional there's
not way around getting to learn how you deal with build tool who is able
to build OSGi-Bundles - maven tycho is one of them, bnd & bndtools
another one, gradle also does understand OSGi but it calls out the bnd.
To get your case running things are quite simple:
* create a feature in your IDE who has
- your.custom.plugin
- org.eclipse.fx.ui.workbench3
* export the feature
* drop your.custom.plugin & org.eclipse.fx.ui.workbench3 to dropins
folder and thing would work
Final word - deploying through dropins is also a bad way to do plugin
installation you should generate a p2-repo and use the install wizard
for real deployment.
Tom
|
|
|
|
|
|
|
|
|
Re: FXCanvas not found during plugin export. [message #1691599 is a reply to message #1691588] |
Wed, 08 April 2015 08:32   |
Eclipse User |
|
|
|
Thomas Schindl wrote on Wed, 08 April 2015 11:01First all on what version of e(fx)clipse are you working:
* 1.2.0
* 2.0.0 nightly
1.2.0 e(fx)clipse plugin installed on Eclipse EE Luna SR2.
Thomas Schindl wrote on Wed, 08 April 2015 11:01
Specify what running means:
a) running with an Inner-Eclipse instance
b) installed into another Eclipse instance
b) installed into another Eclipse EE Luna SR2 instance
As I mentioned before, I've got following tycho/maven projects:
- Plugin project
- Feature project
- Target project
- Aggregator project
- Update site project.
After building the project (by "Run-> Maven build" or from command line mvn clean install/verify/package...), I'm getting ready to install repository in Update site project/target/repository.
I'm installing it in separate Eclipse EE IDE (Luna without any JavaFX support) by Help->Install new software....
Plugin is installing without any problems, but when I'm trying to use(open) some plugin component which is using FXCanvas, then I'm getting exception:
java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas
at basicplugin.actions.SampleAction.run(SampleAction.java:70)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:237)
....
Component is quite simple(action binded with some menu button), for example:
public class SampleAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
public SampleAction() {
}
public void run(IAction action) {
// SWT
try {
Display display = Display.getCurrent();
if (display == null) {
display = new Display();
}
final Shell shell = new Shell(display);
shell.setText("JavaFX / SWT Integration");
shell.setLayout(new FillLayout());
final FXCanvas canvas = new FXCanvas(shell, SWT.NONE); <- here throwing exception
final Scene scene = createFXScene();
canvas.setScene(scene);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()){
display.sleep();
}
}
// display.dispose();
} catch (Throwable e) {
e.printStackTrace();
}
}
.......
}
Plugin components without FXCanvas are working fine.
Quote:This is what the adapter hooks are used for they modify the classloader
hierarchy to include jfxswt.jar. What happens if you run with
-Defxclipse.osgi.hook.debug=true.
After setting it and opening component that is using FXCanvas, I'm getting:
org.eclipse.m2e.logback.configuration: Initializing logback
FXClassLoader#createJREBundledClassloader - Started
FXClassLoader#createJREBundledClassloader - Assumed location (Java 8/Java 7): /usr/lib/jvm/java-8-oracle/jre/lib/ext/jfxrt.jar
FXClassLoader#createJREBundledClassloader - SWT is available use different loading strategy
FXClassLoader#createJREBundledClassloader - Searching for SWT-FX integration at /usr/lib/jvm/java-8-oracle/jre/lib/jfxswt.jar
FXClassLoader#createJREBundledClassloader - Found SWT/FX
FXClassLoader#createJREBundledClassloader - Delegate to system classloader
FXClassLoader.SWTFXClassloader#init - Primary Loader sun.misc.Launcher$ExtClassLoader@a3e458
FXClassLoader.SWTFXClassloader#init - Lastresort Loader org.eclipse.osgi.internal.loader.EquinoxClassLoader@320be73[org.eclipse.swt:3.103.2.v20150203-1313(id=672)]
FXClassLoader#createJREBundledClassloader - Ended
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.Parent'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.layout.HBox'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.paint.Paint'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.paint.Color'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.effect.Effect'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.effect.MotionBlur'
FXModuleClassloader#findLocalClass trying to load class 'javafx.scene.effect.Reflection'
java.lang.NoClassDefFoundError: javafx/embed/swt/FXCanvas
at basicplugin.actions.SampleAction.run(SampleAction.java:59)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:237)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3799)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3409)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
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:483)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: javafx.embed.swt.FXCanvas cannot be found by BasicPlugin_1.0.0.201504081219
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 33 more
[Updated on: Wed, 08 April 2015 08:49] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: FXCanvas not found during plugin export. [message #1693840 is a reply to message #1693836] |
Tue, 28 April 2015 12:39  |
Eclipse User |
|
|
|
On 28.04.15 18:20, Darren Hurt wrote:
>
> Ok, so I assume I shouldn't need to copy fxswt.jar to the ext folder and
> that e(fx)clipse should resolve the jar (and it's downstream
> dependencies) if I have the correct set-up in my target platform and
> manifest.
No if e(fx)clipse tooling is successfully installed you don't have to do
any copying!
>
> The tutorial (https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial2)
> doesn't work for me. Presumably had this template appeared and worked it
> would have created a project with the correct dependencies and I
> wouldn't have had to ask. However it doesn't even appear.
This leads me to believe that e(x)clipse is not appropiately installed.
Are there other JavaFX entries in the New Project wizard? If you open
the Host OSGi console and look at the org.eclipse.fx bundles what is
their state?
> That being so, what are the dependencies?
>
> So let's assume I follow the instructions for the target platform as
> given here (for 1.2.0). What dependencies etc. do i need to add to my
> project in order to 'see' (compile time etc.) the Java FX SWT classes
> and for them to be present and working when I run an Eclipse Application
> launcher that includes all of these dependencies on its class-path?
> Up until now I've just added org.eclipse.fx.javafx as a dependency.
> Also, do I need the 'Imported packages' to include the javafx.embed.swt
> in the 'Imported packages'?
> Assume my launcher has the vm argument
> (-Dosgi.framework.extensions=org.eclipse.fx.osgi) set.
>
How is the target platform defined? Please provide a screenshot. I
somehow have to reproduce your setup to see what's going wrong.
Tom
|
|
|