This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194263 - java.lang.NoClassDefFoundError thrown when start to debug project
Summary: java.lang.NoClassDefFoundError thrown when start to debug project
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 12:58 UTC by AndezFernandez
Modified: 2017-05-08 20:41 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
error (45.32 KB, application/octet-stream)
2014-12-08 15:00 UTC, divesh179
Details

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
Comment 6 divesh179 2014-12-08 15:00:05 UTC
Created attachment 150958 [details]
error
Comment 7 Martin Balin 2016-07-07 07:16:37 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss
Comment 8 blacksheep7198 2016-09-06 18:48:17 UTC
I had the same issue. Randomly occurs when i update a class in Netbeans. I was able to resolve this by making any random change, in my case I inserted a space, in the class which is "missing". I then hit save and did a "clean$build". 

This resolved the issue for me. I have encountered it several times in the last couple of years with various versions of netbeans. I'm currently on 8.1.
Comment 9 rene_hof 2017-05-08 20:27:55 UTC
I have the same issue in Netbeans 8.2 on Windows 8.1. Very frequently occurring and can be resolved by inserting a space in the respective class and saving the file. 
I suspect that the problem occurs when I hit run before the background compilation of the file completes.
Comment 10 rene_hof 2017-05-08 20:41:26 UTC
Update: I just found out that it occurs in conjunction with a low memory error. 
http://wiki.netbeans.org/InsufficientMemoryToIndexRoot
I'm using Netbeans in 64 bit on Windows 8.1 64 bit. I haven't changed any Xmx settings and my machine has 16 GB RAM. Netbeans is using 1300 MB of that although my project has only 3 classes. The Windows task manager says 35% of RAM are used, which means there should be 65% of RAM free.