Reputation: 33
I am trying to use the JFXPanel class with the Apache Felix Maven Bundle Plugin. I´ve tried to export the JavaFX classes into the bundle with the tag but I always obtain the NoClassDefFoundError exception:
ERROR 10:08:15 Uncaught Exception in thread 'AWT-EventQueue-0'
java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
at edu.stanford.bmir.protege.examples.view.Metrics.<init>(Metrics.java:42) ~[na:na]
at edu.stanford.bmir.protege.examples.view.ExampleViewComponent.initialiseOWLView(ExampleViewComponent.java:17) ~[na:na]
at org.protege.editor.owl.ui.view.AbstractOWLViewComponent.initialise(AbstractOWLViewComponent.java:43) ~[na:na]
at org.protege.editor.core.ui.view.View.createContent(View.java:413) ~[na:na]
at org.protege.editor.core.ui.view.View.createUI(View.java:220) ~[na:na]
at org.protege.editor.core.ui.view.View$1.hierarchyChanged(View.java:124) ~[na:na]
at java.awt.Component.processHierarchyEvent(Component.java:6700) ~[na:1.8.0_121]
at java.awt.Component.processEvent(Component.java:6319) ~[na:1.8.0_121]
at java.awt.Container.processEvent(Container.java:2236) ~[na:1.8.0_121]
at java.awt.Component.dispatchEventImpl(Component.java:4889) ~[na:1.8.0_121]
at java.awt.Container.dispatchEventImpl(Container.java:2294) ~[na:1.8.0_121]
at java.awt.Component.dispatchEvent(Component.java:4711) ~[na:1.8.0_121]
at java.awt.Component.createHierarchyEvents(Component.java:5549) ~[na:1.8.0_121]
at java.awt.Container.createHierarchyEvents(Container.java:1445) ~[na:1.8.0_121]
at java.awt.Container.createHierarchyEvents(Container.java:1441) ~[na:1.8.0_121]
at java.awt.Container.createHierarchyEvents(Container.java:1441) ~[na:1.8.0_121]
at java.awt.Container.createHierarchyEvents(Container.java:1441) ~[na:1.8.0_121]
at java.awt.Container.createHierarchyEvents(Container.java:1441) ~[na:1.8.0_121]
at java.awt.Component.show(Component.java:1639) ~[na:1.8.0_121]
at java.awt.Component.show(Component.java:1671) ~[na:1.8.0_121]
at java.awt.Component.setVisible(Component.java:1623) ~[na:1.8.0_121]
at javax.swing.JComponent.setVisible(JComponent.java:2644) ~[na:1.8.0_121]
at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:394) ~[na:1.8.0_121]
at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:270) ~[na:1.8.0_121]
at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:132) ~[na:1.8.0_121]
at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:67) ~[na:1.8.0_121]
at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:616) ~[na:1.8.0_121]
at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:591) ~[na:1.8.0_121]
at javax.swing.plaf.basic.BasicTabbedPaneUI$Handler.mousePressed(BasicTabbedPaneUI.java:3647) ~[na:1.8.0_121]
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280) ~[na:1.8.0_121]
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:279) ~[na:1.8.0_121]
at java.awt.Component.processMouseEvent(Component.java:6530) ~[na:1.8.0_121]
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) ~[na:1.8.0_121]
at java.awt.Component.processEvent(Component.java:6298) ~[na:1.8.0_121]
at java.awt.Container.processEvent(Container.java:2236) ~[na:1.8.0_121]
at java.awt.Component.dispatchEventImpl(Component.java:4889) ~[na:1.8.0_121]
at java.awt.Container.dispatchEventImpl(Container.java:2294) ~[na:1.8.0_121]
at java.awt.Component.dispatchEvent(Component.java:4711) ~[na:1.8.0_121]
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888) ~[na:1.8.0_121]
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4522) ~[na:1.8.0_121]
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466) ~[na:1.8.0_121]
at java.awt.Container.dispatchEventImpl(Container.java:2280) ~[na:1.8.0_121]
at java.awt.Window.dispatchEventImpl(Window.java:2746) ~[na:1.8.0_121]
at java.awt.Component.dispatchEvent(Component.java:4711) ~[na:1.8.0_121]
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) ~[na:1.8.0_121]
at java.awt.EventQueue.access$500(EventQueue.java:97) ~[na:1.8.0_121]
at java.awt.EventQueue$3.run(EventQueue.java:709) ~[na:1.8.0_121]
at java.awt.EventQueue$3.run(EventQueue.java:703) ~[na:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_121]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) ~[na:1.8.0_121]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90) ~[na:1.8.0_121]
at java.awt.EventQueue$4.run(EventQueue.java:731) ~[na:1.8.0_121]
at java.awt.EventQueue$4.run(EventQueue.java:729) ~[na:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_121]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) ~[na:1.8.0_121]
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) ~[na:1.8.0_121]
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) [na:1.8.0_121]
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) [na:1.8.0_121]
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) [na:1.8.0_121]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [na:1.8.0_121]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) [na:1.8.0_121]
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) [na:1.8.0_121]
Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel not found by protege.plugin.examples [30]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574) ~[org.apache.felix.main.jar:na]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79) ~[org.apache.felix.main.jar:na]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018) ~[org.apache.felix.main.jar:na]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
... 62 common frames omitted
This is my pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.stanford.protege</groupId>
<artifactId>protege.plugin.examples</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Protege Plugin Examples</name>
<description>Example plug-ins for the Protege Desktop ontology editor, e.g., views, menu items, etc.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.osgi.framework.system.packages.extra>
javafx.animation,javafx.application,
javafx.collections,
javafx.embed.swing,
javafx.geometry,
javafx.scene,javafx.scene.layout,
javafx.scene.transform,
javax.swing,
javax.swing.border,
org.osgi.framework
</org.osgi.framework.system.packages.extra>
</properties>
<dependencies>
<dependency>
<groupId>edu.stanford.protege</groupId>
<artifactId>protege-editor-owl</artifactId>
<version>5.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>11</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<!-- Use resource filtering to replace references to the artifactId in the plugin.xml file -->
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>org.protege.editor.owl.ProtegeOWL</Bundle-Activator>
<Bundle-ClassPath>.</Bundle-ClassPath>
<Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Vendor>The Protege Development Team</Bundle-Vendor>
<Embed-Dependency>javafx</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>
org.protege.editor.owl.*;version="5.0.0", <!-- equivalent to [5.0.0,infinity) -->
com.sun.javafx, com.sun.javafx.animation, com.sun.java
fx.applet, com.sun.javafx.application, com.sun.javafx.beans, com.sun.
javafx.beans.event, com.sun.javafx.binding, com.sun.javafx.charts, co
m.sun.javafx.collections, com.sun.javafx.css, com.sun.javafx.css.conv
erters, com.sun.javafx.css.parser, com.sun.javafx.cursor, com.sun.jav
afx.effect, com.sun.javafx.embed, com.sun.javafx.event, com.sun.javaf
x.font, com.sun.javafx.font.coretext, com.sun.javafx.font.directwrite
, com.sun.javafx.font.freetype, com.sun.javafx.font.t2k, com.sun.java
fx.fxml, com.sun.javafx.fxml.builder, com.sun.javafx.fxml.expression,
com.sun.javafx.geom, com.sun.javafx.geom.transform, com.sun.javafx.g
eometry, com.sun.javafx.iio, com.sun.javafx.iio.bmp, com.sun.javafx.i
io.common, com.sun.javafx.iio.gif, com.sun.javafx.iio.ios, com.sun.ja
vafx.iio.jpeg, com.sun.javafx.iio.png, com.sun.javafx.image, com.sun.
javafx.image.impl, com.sun.javafx.jmx, com.sun.javafx.logging, com.su
n.javafx.media, com.sun.javafx.menu, com.sun.javafx.perf, com.sun.jav
afx.print, com.sun.javafx.property, com.sun.javafx.property.adapter,
com.sun.javafx.robot, com.sun.javafx.robot.impl, com.sun.javafx.runti
me, com.sun.javafx.runtime.async, com.sun.javafx.runtime.eula, com.su
n.javafx.scene, com.sun.javafx.scene.control, com.sun.javafx.scene.co
ntrol.behavior, com.sun.javafx.scene.control.skin, com.sun.javafx.sce
ne.control.skin.caspian, com.sun.javafx.scene.control.skin.caspian.im
ages, com.sun.javafx.scene.control.skin.modena, com.sun.javafx.scene.
control.skin.resources, com.sun.javafx.scene.input, com.sun.javafx.sc
ene.layout, com.sun.javafx.scene.layout.region, com.sun.javafx.scene.
paint, com.sun.javafx.scene.shape, com.sun.javafx.scene.text, com.sun
.javafx.scene.transform, com.sun.javafx.scene.traversal, com.sun.java
fx.scene.web, com.sun.javafx.scene.web.behavior, com.sun.javafx.scene
.web.skin, com.sun.javafx.sg, com.sun.javafx.sg.prism, com.sun.javafx
.sg.prism.web, com.sun.javafx.stage, com.sun.javafx.text, com.sun.jav
afx.tk, com.sun.javafx.tk.quantum, com.sun.javafx.util, com.sun.javaf
x.webkit, com.sun.javafx.webkit.drt, com.sun.javafx.webkit.prism, com
.sun.javafx.webkit.prism.resources, com.sun.javafx.webkit.prism.theme
, com.sun.javafx.webkit.theme, javafx, javafx.animation, javafx.appli
cation, javafx.beans, javafx.beans.binding, javafx.beans.property, ja
vafx.beans.property.adapter, javafx.beans.value, javafx.collections,
javafx.collections.transformation, javafx.concurrent, javafx.css, jav
afx.embed, javafx.embed.swing, javafx.event, javafx.fxml, javafx.geom
etry, javafx.print, javafx.scene, javafx.scene.canvas, javafx.scene.c
hart, javafx.scene.control, javafx.scene.control.cell, javafx.scene.e
ffect, javafx.scene.image, javafx.scene.input, javafx.scene.layout, j
avafx.scene.media, javafx.scene.paint, javafx.scene.shape, javafx.sce
ne.text, javafx.scene.transform, javafx.scene.web, javafx.stage, java
fx.util, javafx.util.converter,
</Export-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<pde>true</pde>
</configuration>
</plugin>
</plugins>
</build>
</project>
Upvotes: 1
Views: 4502
Reputation: 1316
TO DO: from your pom.xml remove org.openjfx dependecy as it does not contain javafx/embed package. check this repository.
Use the below dependency to fix the issue
JFXPanel is a component to embed JavaFX content into Swing applications.
In eclipse, right click project --> properties --> Libraries --> Add external jar and choose the jfxrt jar file.
Location of jfxrt.jar in Oracle Java 7:
<JRE_HOME>/lib/jfxrt.jar
Location of jfxrt.jar in Oracle Java 8:
<JRE_HOME>/lib/ext/jfxrt.jar
The JRE_HOME will depend on where you have installed the Java.
Maven plugin to run JavaFX 11+ applications.
Gradle plugin to run JavaFX 11+ applications.
I hope this helps.
Upvotes: 1