Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError from every class every day

Tags:

I have tried reinstalling netbeans, I have tried reinstalling java. I'm not sure what's going on but I get this exception at random from every class until I restart netbeans. Anyone with similar problems?

run:

Exception in thread "main" java.lang.NoClassDefFoundError: com/company/utilities/formatters/DateFinder     at com.protocase.db.DatabaseAdapter.<init>(DatabaseAdapter.java:44)     at packagingqueries.PackagingQueries.getBatchIDsForOperation(PackagingQueries.java:42)     at packagingqueries.PackagingQueries.main(PackagingQueries.java:20) Caused by: java.lang.ClassNotFoundException: com.protocase.utilities.formatters.DateFinder     at java.net.URLClassLoader$1.run(URLClassLoader.java:200)     at java.security.AccessController.doPrivileged(Native Method) 
like image 544
davidahines Avatar asked Jun 08 '11 20:06

davidahines


People also ask

How do I fix Java Lang NoClassDefFoundError error?

lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.

Why am I getting a NoClassDefFoundError in Java?

The NoClassDefFoundError is a runtime error in Java that occurs if the Java Virtual Machine (JVM) or a ClassLoader instance attempts to load the definition of a class that could not be found. The class definition exists at compile-time but is not available at runtime.

What's the difference between a ClassNotFoundException and NoClassDefFoundError?

ClassNotFoundException is an exception that occurs when you try to load a class at run time using Class. forName() or loadClass() methods and mentioned classes are not found in the classpath. NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time.


1 Answers

Sometimes, the NetBeans local cache directory becomes corrupted (either because the application crashed earlier or because something else/undefined happened). NetBeans starts to behave strangely. Re-installing does not help, because the local cache directory is not always deleted.

If you are 100% sure your application does not have a path problem:

  1. Close NetBeans
  2. If you are on Windows go to c:\Users\youruserid\.netbeans\7.0 (else find the corresponding directory on your system)
  3. Delete the content completely
  4. Restart NetBeans

NetBeans will recreate the content of this directory. This may solve your issue. If it does not, then your issue is in the configuration of your application or in a corrupted library for sure.

If the location where these files are stored runs out of space for writing, this problem can arise. As usual, one needs to make space...

like image 56
Jérôme Verstrynge Avatar answered Oct 05 '22 10:10

Jérôme Verstrynge