This question already has answers here:
Java 9 JavaFX Preloader
(3 answers)
Problem With JavaFX/Intellij Setting When Try To Use LauncherImpl For Preloader
(1 answer)
Closed 1 year ago.
I have a JavaFX application which compiles to native using GluonFx plugin.
I want to add a Preloader to show when starting. I managed it by changing the initialization from:
Application.launch(MainView.class, args) to LauncherImpl.launchApplication(MainView.class, MyPreloader.class, args)
The compilation process executes till the end with no errors, but the app doesn't boot.
If I try to run the agent (mvn gluonfx:runagent) I have the following error:
cannot access class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.application to unnamed module
Someone knows how to solve this, or what other way can I use to load my Preloader?
PS: Running from the IDE works. The problem is after compilation to native
Thanks in advance
I've found the solution by using the answer in this ticket:
Java 9 JavaFX Preloader
Replaced:
LauncherImpl.LauncherImpl.launchApplication(MainView.class, MyPreloader.class, args)
by
System.setProperty("javafx.preloader", MyPreloader.class.getCanonicalName());
Application.launch(MainView.class, args);
This question already has answers here:
Unable to derive module descriptor for auto generated module names in Java 9?
(2 answers)
Closed 5 years ago.
I want to use Java 9 in my app. One of my dependencies has a jar name:
sdk-http-ahc-2_0
Unfortunately, when I try to change it to automatic module, the name for the module is not valid.
requires sdk.http.ahc.2_0; // not valid
Am I missing something with naming the module? What are my other options here?
The problem is that the module system does not identify 2_0 as a version number and hence doesn't strip it when determining the automatic module name. Unfortunately, 2_0 is not a valid Java identifier and can hence not be used as a segment in a module name.
The solution is to either rename the JAR or add the Automatic-Module-Name entry to the JAR's manifest:
Create a file manifest.txt with the following content:
Automatic-Module-Name: sdk.http.ahc
Then use jar to append that line to the existing manifest:
jar --update --file sdk-http-ahc-2_0.jar --manifest=manifest.txt
Note that locally modifying existing JARs (name or manifest) can cause problems down the road. Consider changing the Maven version of the file to something like 2.0-patched-auto-name (or similar) and add it to your local Maven repository. If the project is shared with other developers and you have a local Nexus, you can put it in there. Otherwise send a mail to everyone with the steps to add it to their local repo. 😜
This question already has answers here:
Random NoClassDefFound error in Web Application
(1 answer)
Why am I getting a NoClassDefFoundError in Java?
(31 answers)
Closed 6 years ago.
I am trying to run a spring project in intellij.
When I import the code and add the necessary jars, it there is no error during compile time. However, when I run the project, I get the following error
Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/company/access/KeyValueAccess
The KeyValueAccess class is present in the cassandra-access-1.12.0.jar as highlighted in the image.
I have tried to add jars as modules and also as libraries.
What is the correct way to avoid this runtime error?
PS: This is the case for only manually added external libraries. The libraries downloaded with maven work just fine.
Edit
The following code generates the exception
#Bean
public KeyValueAccess keyValueAccess() {
return new CassandraAccessDatastax(); //This doesn't matter, the return type itself creates the exception
}
Exception generated is as below:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.worksap.bootcamp.webeditor.config.WebEditorConfig#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com/company/access/KeyValueAccess
I also checked that the jar does it fact have the required class files.
Edit2
I manually ran maven to add the jar files, so I can now find them in ~/.m2/repository. When I call a class in the jar, it seems to find it but when that class calls another class in the same jar, it gives java.lang.NoClassDefFoundError
As I see in your screen, you added cassandra manually, not using maven? So this may be the problem. Add dependencies to pom.xml. Watch them here.
Also check if your dependencies added to special module, not just in libraries. Go to file->project structure->modules. Choose your module in which you use cassandra and click on "dependencies" tab. Press "+" and "library" from dropdown menu and then add your libraries to project.
I'm having the following situation:
I want to extend the functionality of a given plugin A (I have it's source code and start it by running the project as an Eclipse Application which opens a new Eclipse IDE which provides the plugins functionality) with an plugin B I am writing.
My plugin does run when I run it as a Java Application. Let's assume it just prints Hello World in the console. What I want is that I can call the function which does that from plugin A.
What I did:
I added my plugin B to plugin As Required Plugin-Ins.
I create an instance of the class which implements the Hello World-print and call the function inside a method of plugin A (I also tried to make the method static and call it without creating an instance which resulted in exactly the same errors).
I created an Extension Point in plugin B and added it as an Extension in plugin A. I just set the ID and name in the Extension Point.
What happens:
When the instance of the class in plugin B should be created, the program crashes with this error:
java.lang.NoClassDefFoundError: de/name_of/plugin_b/package/ClassName
[...]
Caused by: java.lang.ClassNotFoundException: de.name_of.plugin_b.package.ClassName cannot be found by de.name_of.plugin_a.package_1.0.0.qualifier
I guess I'm missing something imporant - can someone help me out on what it is?
Edit 2:
I've just read that I have to add "." to the classpath. Seems like this solved the issue! Thanks for making me dig deeper into the manifest, greg!
I do get a different error now tho, which also seems to be connected to me making mistakes when creating the plugin as I do not get this error when I run plugin B as a Java Application.
java.lang.NoSuchMethodError: org.apache.lucene.store.FSDirectory.open(Ljava/nio/file/Path;)Lorg/apache/lucene/store/FSDirectory;
The problem is, tho, that this method does exists (see lucene API here).
As seen in the manifest, I added the lucene-jars to the dependencies of plugin B.
You need to include every package that other plugins use in the Export-Package section of your plugin. In the MANIFEST.MF editor this is on the 'Runtime' tab in the 'Exported Packages' section.
You don't need an extension point to make this work.
I'm trying to create a simple plugin in eclipse. When I run the application, I see this error in log file:
org.osgi.framework.BundleException : The activator for bundle
org.x.y.Activator for bundle org.x.y is invalid.
Do you have any idea about this error?
Check your build.properties section
If it doesn't properly specify what's supposed to be in the final binary result, it will not work. Check the .class files are where the MANIFEST.MF says they will be.
from EclipseZone, another reason for this error message:
If you see a message in the log like
The activator org.example.FooActivator for bundle org.example.foo is invalid
, then this usually means there has been a ClassNotFoundException trying to load the class in the first place, before it's even got to the start() method.
penguru adds:
The error occurs when I try create a new object from any other class in the constructor of activator class. Isn't it legal to create an object in activator plugin ?
If that class if from another plugin which has not yet been "activated", that could be your problem.
If that class is not found, that would also invalidate your plugin activator.
Basic advice: you may be better off with your initializations done in the start() method of Activator rather than its constructor.
I also faced same issue while importing plugins from different workspace. Basically, it is the bundle classpath where the framework looks for while loading the classes. When you import to a different workspace, make sure you change the class path to point to appropriate location i.e. where the class file are present.
After modifying the classpath try to clean and re-build and re-run. It should work..hopefully..
OK, I hate to be captain obvious here, but I've made this mistake before. This can also happen when you forget to extend BundleActivator.
If you have move the eclipse workspace to a new path, then you should use the project->clean before your plugin build, Or you would meet this problem.
I spent some time with this problem. Finally I noticed that the ClassNotFoundExceptions were not in line with my code, they were coming from wrong (old) packages. I checked if there was some other plugin which was messing with my debugs/exports and indeed there was, my own plugin!
So a simple fix to try if you're facing this and the CNFE's are not in line with your code:
Go to "Install new software"
Click on "already installed"
Remove all instances of your package/plugin and restart
Likely this was caused because I changed the plugin ID, making Eclipse treat it as a new plugin.
Another good site to take a look if you're getting frustrated and stuck: http://www.eclipsezone.com/eclipse/forums/t99010.html
In my case there was this Message "Activator ..invalid" but in the next exceptions there were ClassNotFound Exceptions in a Bundle were i didnt change something..
Guu(Posted a solution too) is my hero, After increasing
Bundle-ManifestVersion: 2
to
Bundle-ManifestVersion: 3
everything works :)
I got the same exception. The underlying problem was a ClassCastException. My bundle requires org.osgi.core 4.3 whereas the equinox launcher uses 4.2.
Regards
Roland
This can also happen if you name a bundle after a package in another bundle.
So:
if you have Bundle A which contains package org.my.package.name.function,
and you create bundle B with name org.my.package.name.function,
=> then the system may look for the activator there, and not find any.
I found the reason of the error. The error occurs when i try create a new object from any other class in the constructor of activator class. Isn't it legal to create an object in activator of plugin ?
In my case this exception was because of inability of Eclipse custom class loader to resolve and load all depending classes from other plugins in-time. I am not Eclipse super-guru so maybe it was my fault.
However it was fixed by disabling lazy loading of plugin. In GUI on Overview tab of MANIFEST.MF editor uncheck Activate this plug-in when one of its classes is loaded. Or directly in MANIFEST.MF delete line
Bundle-ActivationPolicy: lazy
Another captain obvious: If you change the paths of your source files (e.g. src/ to src/main/java), but forget to update build.properties, the compilation will always succeed, but your plugin will never work.
I had the same error, in my case I created my own constructor with parameters. But I didn't provide a default constructor. So after removing my constructor and initialized all within the start() method, it worked like charme.
I also met the same error. The activator XX for bundle XX is invalid, and the ClassNotFoundException.
I checked plugins\ directory, and could not find the class needed.
--
Because there is no jar file containing the needed class, there is only the corresponding directory.
For example, there is no com.hh.jar, but only com.hh directory.
So, there must be something wrong about creating the com.hh.jar.
if com.hh.jar reference other plugins, then also check them.
I solved the problem by editing MANIFEST.MF.
Open it by Plug-in Manifest Editor, in runtime tab, add needed packages in "Exported Packages".
and in the "classpath", add needed libraries, and, "." (current directory, IMPORTANT)
I have also run into this isue when 'bundle-izing' plain jar files. If some dependencies are not resolved, or jars depend on a higher JAVA version than the one you're using, the activator will not start, giving the above exception. The quick way to find out if this is the problem is to remove the jars from the bundle-classpath (runtime tab of the manifest) and check if the activator will run correctly.