I will briefly explain my problem:
I have a while-loop and inside I call some methods. Inside one of the methods I have this error: java.lang.NoClassDefFoundError, which is been caught and the while continues.
The problem is that a few seconds later as the while keeps running the same method doesn't throw that error and it executes correctly.
Now, you are going to say that the first time the method tried to call something that was not found and the second time the program followed a different path.
This is not the case because the class that the error says it didn't find is being called by practically everything. And 2 times in a row (while the loop was running) I had this error: NoClassDefFoundError but then the class that was appearing at the error gets executed correctly.
That error happened during one execution. Meaning that the program started, the while-loop was repeating, First loop: NoClassDefFoundError, Second loop: NoClassDefFoundError, The other loops No Problems, the class that was giving the error works OK.
I have searched the internet for answers and I have found from this site:
http://mindprod.com/jgloss/runerrormessages.html
the following:
If your NoClassDefFoundError occurs only sporadically, here is a possible cause: You are running some classes in a jar file which is stored on a network mapped drive in MS Windows. Sun keeps the jar files open in order to re-load classes which haven’t been used in a while, and occasional network problems will force the jar to close. The JVM doesn’t know to re-open the jar when the network mapped drive reconnects, and simply reports that various classes (different each time) no longer exist. The solution is either make sure the network is reliable, use a network file system which doesn’t close if drives are temporarily unavailable, or locate all jar files on local drives.
Do you have any other suggestions apart from this, because the error doesn't happen all the time, but some times the class works, and some other times NoClassDefFoundError for that class