1

I don't understand NoClassDefFoundError in the context of running an OpenEJB client:

thufir@doge:~$ 
thufir@doge:~$ java -classpath .:NetBeansProjects/HelloClient/dist/HelloClient.jar:apache-openejb-4.7.1/lib/openejb-client-4.7.1.jar org.acme.HelloClient
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ejb/EJBHome

The missing class, EJBHome, is in the libray for the project:

libraries

Yet doesn't show up in the manifest. How do I either force NetBeans to add the JAR to the classpath (if that's the solution), or, include the JAR in the classpath during execution?

Community
  • 1
  • 1
Thufir
  • 8,216
  • 28
  • 125
  • 273
  • I have found this type of error while version mismatch. You may check you current jdk version and the minimum required jdk version for the jar – Razib Mar 07 '15 at 10:38

2 Answers2

3

NoClassDefFoundError means that the class was present at compile time, but is not present at run time. So probably your deploy has'nt that class.

Davide Lorenzo MARINO
  • 26,420
  • 4
  • 39
  • 56
  • Ok. Why isn't it there? NetBeans knows about that class, I added it to the "project" so that it compiles with that class on the classpath. Correct? Why isn't it included in the deploy? How do I force the IDE to add it to the dist/lib/ folder as is my intent? Your simple answer is awesome, by the way :) – Thufir Mar 07 '15 at 10:33
  • I see that you execute the code from command line. Check if in the manifest of the jar there are references to the jars that you need. Here is how to do it http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html , probably if correctly configured NetBeans should do that for you. – Davide Lorenzo MARINO Mar 07 '15 at 10:38
2

You include the jar file in the classpath when you execute by simply putting it in that list of jar files you've already got - you're already specifying openejb-client-4.7.1.jar etc; just add javaee-api-7.0.jar to that list (with the right directory, of course).

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • thank you, this worked. I accepted Davide's answer because he explained the error in language I could understand. – Thufir Mar 07 '15 at 10:43