Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener(class not found even there is no errror in the import)
java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784953] Fri, 06 April 2018 09:47 Go to next message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
I have tried to implement the MapChangeListener in JavaFX, and I run this example in Intellij Idea (windows):

// Use Java Collections to create the List.
Map<String,String> map = new HashMap<String,String>();

// Now add observability by wrapping it with ObservableList.
ObservableMap<String,String> observableMap = FXCollections.observableMap(map);
observableMap.addListener(new MapChangeListener() {
@Override
public void onChanged(MapChangeListener.Change change) {
System.out.println("Detected a change! ");
logerKuraPI("Detected a change! ");
}
});

// Changes to the observableMap WILL be reported.
observableMap.put("key 1","value 1");
System.out.println("Size: "+observableMap.size());
logerKuraPI("Size: "+observableMap.size());

// Changes to the underlying map will NOT be reported.
map.put("key 2","value 2");
System.out.println("Size: "+observableMap.size());
logerKuraPI("Size: "+observableMap.size());


and it worked fine, but when I tried to insert the code in my eclipse project (Linux) I got these errors:


java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.newInstance(Class.java:412)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.createInstance(ServiceComponent.java:493)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.createInstance(ServiceComponentProp.java:270)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:331)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
at org.eclipse.equinox.internal.ds.InstanceProcess.registerService(InstanceProcess.java:536)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:213)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.ClassNotFoundException: javafx.collections.MapChangeListener cannot be found by fileloger_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)


Anyone can help me to figure out what's wrong? Even there is no error when importing:



import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableMap;
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784954 is a reply to message #1784953] Fri, 06 April 2018 10:00 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
Hi,
is the manifest file correct, with all the required imports?

Best regards,
Matteo
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784955 is a reply to message #1784954] Fri, 06 April 2018 10:07 Go to previous messageGo to next message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
Hi dear Matteo,

The Manifes file should be okay:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Configurable
Bundle-SymbolicName: org.eclipse.kura.example.configurable
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.kura.configuration;version="1.1.2",
org.osgi.service.component;version="1.2.2",
org.slf4j;version="1.7.21"
Service-Component: OSGI-INF/component.xml
Bundle-ClassPath: .


the problem is that from Java 8 the: javafx.collections.MapChangeListener;
is by default included in the jdk.
so I don't need to declare it as class path, tha's what I found online
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784956 is a reply to message #1784955] Fri, 06 April 2018 10:19 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
It could, but OSGi is in general more problematic with this set of things :-)
I would suggest to try to use the eclipse tools and see if automatically or manually the import can be included.

If that will not work, we will try to explore different options.

Best regards,
Matteo
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784957 is a reply to message #1784956] Fri, 06 April 2018 10:26 Go to previous messageGo to next message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
Thank you very much for your fast reply,
but I am sorry I couldn't figure out what you mean by eclipse tools ?
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784958 is a reply to message #1784957] Fri, 06 April 2018 10:28 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
When you open the manifest, don't you have a view like this?
https://eclipse.github.io/kura/assets/images/hello_example/media/image5.png
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784959 is a reply to message #1784958] Fri, 06 April 2018 10:30 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
In the right part of the view, you should have the "Imported Packages" section where you can specify what to import.
In the "Automated Management of Dependencies" you can use a tool to automatically find missing dependencies.
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1784964 is a reply to message #1784959] Fri, 06 April 2018 10:50 Go to previous messageGo to next message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
The problem is:
1- There no error in the ide when I build the code,
2- Even if I want to add the dependency in "Automated Management of Dependencies", I can't find it bcz it belong to the JDK, or maybe I don't know what dependency I should bbe looking for.

but I think the problem is how to add an integrated jdk jar file to the class path, it was an external library there is no problem, but it's the jfxwt.jar I am using included in the jdk folder.
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1785175 is a reply to message #1784959] Tue, 10 April 2018 09:58 Go to previous messageGo to next message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
Dear Matteo,

Sorry for my continues questions, I am beginner with OSGI.
I am still stuck, I couldn't find the necessary dependency for JavaFX,
should I install something ? what I am missing
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1785176 is a reply to message #1785175] Tue, 10 April 2018 10:11 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 264
Registered: July 2015
Location: Italy
Senior Member
Hi,
personally I have a limited experience with javaFX.
Googling I've found the following references that maybe can help you.

Best regards,
Matteo

https://stackoverflow.com/questions/7475195/osgi-how-to-ensure-classpath-consistency?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
https://stackoverflow.com/questions/26485270/efxclipse-equinox-compilation-error?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
https://www.eclipse.org/forums/index.php/t/757375/
Re: java.lang.NoClassDefFoundError: javafx/collections/MapChangeListener [message #1785180 is a reply to message #1785176] Tue, 10 April 2018 10:30 Go to previous message
Ahmed Gharssellaoui is currently offline Ahmed GharssellaouiFriend
Messages: 31
Registered: February 2018
Member
Thank you,
I will update this post if I can figure out the problem.

many thanks
Previous Topic:Creating custom API/web service?
Next Topic:Multiple Instance of Kura
Goto Forum:
  


Current Time: Tue Sep 25 15:00:12 GMT 2018

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

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

Back to the top