Issue locating third party library classes NoClassDefFoundError

I have created an IntelliJ project which is mapped from an identical Eclipse project. (this was not an import)
I use ServiceLoader and Netbeans Lookup to load/lookup a number services I have created.
Both forms of lookup work in my Eclipse project, however only ServiceLoader works in IntelliJ.

I also have an equavalent Netbeans project and both forms of lookup work in my Netbeans project.

When I attemp to use Netbeans Lookup I get.

Exception in thread "main" java.lang.NoClassDefFoundError: org/openide/util/Lookup
 at edu.mit.ll.bluestreak.multiintmanager.MutiIntAppTest.main(MutiIntAppTest.java:37)
Caused by: java.lang.ClassNotFoundException: org.openide.util.Lookup
 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
 ... 1 more

So the code compiles but does not run.


I have added the META-INF directory to the project and is configured correclty with a services directory and files defining the services.
I have also added the META-INF directory to the out directory.

Just a side note Netbeans Lookup sits on top of ServiceLoader, so since service loader works I would expect Netbeans lookup to work.
I have a libs directory populated with the required jar files.
I have also added the jar file dependencies to the module definition of the project.

Any help in getting this to work would be appriciated.

Another note the source from these project comes from another larger map project created in Netbens RCP so not to maintain two different code threads
I would like to use Netbeans Lookup. Which actually works rather well, and is bit simpler to use then ServiceLoader.

1 comment
Comment actions Permalink

I solved this issue re-creating the intellij project. After rebuilding the project I place my META-INF Directory under production and the services now are found. The library issue just went away once I created a new project. So third party libraries are getting resolved. So both methods of loading services is working.

However I am creating an artifact generating a jar file which will be used to plug into another application. The third party libraries are not getting resolved in the artifact. The services are via including the META-INF services directory.

Any help on resolving the class path issue with the artifact would be appreciated. I place the libs directory into the artifacts jar file. I set the class path of the MANIFEST.MF file via the genarate manifest windows class path. I set my classpath as libs/nameOfJarFile. Not sure if this correct.

My jar artifact looks like

edu – source director
images
libs – contains third party libraries
META-INF – directory


any help would be appreciated, I am new to Intellij

0

Please sign in to leave a comment.