Bug 194263 - java.lang.NoClassDefFoundError thrown when start to debug project
java.lang.NoClassDefFoundError thrown when start to debug project
Status: NEW
Product: java
Classification: Unclassified
Component: Compiler
6.x
PC Windows 7
: P3 with 1 vote (vote)
: TBD
Assigned To: Dusan Balek
issues@java
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-12 12:58 UTC by AndezFernandez
Modified: 2011-03-31 15:32 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description AndezFernandez 2011-01-12 12:58:12 UTC
I am getting the java.lang.NoClassDefFoundError once I have compiled my project and click on the debug button to start debugging it.

This only seems to happen to me (on 6.9.1) out of our developers.  The others are on earlier versions of netbeans.  It keeps happening quite a lot in my main project we work on, although even with a simple application (one class) it has occured.

The only resolution I have is to move package folders from my source, build and let it fail, then move them back in to it.  It is not specific source files - I have to chop and change the files by trial and error before it starts running again.  This is really frustrating.  Clean and build never resolves this issue once it starts happening.

The debug output is as follows:

Output:

debug:
java.lang.NoClassDefFoundError: SentinelCore/Sentinel
Caused by: java.lang.ClassNotFoundException: SentinelCore.Sentinel
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: SentinelCore.Sentinel.  Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
Comment 1 AndezFernandez 2011-01-12 13:03:20 UTC
Following on from the above instance...

If I: 

1. Rename SentinelCore.java to xxxSentinelCore.java 
2. Build - the build fails.
3. Rename xxxSentinelCore.java to SentinelCore.java 
4. Build - build successful
5. Start Debug
6. The debugger stops on the constructor of a class - in this instance ModelData.
7. Click on continue and the following is output to the Output window:

java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - missing method body, or declare abstract
        at SentinelCore.ModelData.<init>(ModelData.java:56)
        at SentinelCore.Sentinel.<clinit>(Sentinel.java:55)
Could not find the main class: SentinelCore.Sentinel.  Program will exit.
Exception in thread "main" Java Result: 1
Comment 2 Martin Entlicher 2011-01-14 09:57:10 UTC
This has nothing to do with debugger, you'd get the same error when running the program.
Try to disable "Compile on Save" on your project and rebuild.
Moving to Java module to suggest the best resolution of this...
Comment 3 Dusan Balek 2011-01-14 22:12:46 UTC
Are you able to create a reproducible test case?
Comment 4 AndezFernandez 2011-01-15 20:30:21 UTC
I'm afraid I cannot.  The error seems pretty random.  There appears to be no set of steps to do this.  

It has mainly occured when I have done a get latest from Sourcesafe, but I'm 99.9% sure I have clicked clean and build first.

But in the case when I had a pretty much empty project it has occurred.
Comment 5 AndezFernandez 2011-03-31 15:32:28 UTC
I thought there must be something incorrectly cached for this.

I have come across the cached user information for projects in Netbeans under the folder C:\Users\panderson\.netbeans\6.9\var\cache for my self.  I have deleted the entire structure under this folder and re-ran my project after restarting netbeans and it starts working again - i.e. java.lang.NoClassDefFoundError does not appear.

Does this shine any more light on the subject?

Also, my cache varies in size.  It is typically 100MB which seems a lot - but our project contains a large number of classes and can take up to 3 minutes to build.

Many thanks,

Andez


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo