-1

I have running an application (3rd party, not selfprogrammed) on tomcat. After some days I get an java.lang.NoClassDefFoundError error insome situation. After a restart of the JVM it runs fine again.

What could be the reason ? Doesn't the classloader loads all classes at start ?

Stacktrace:

java.lang.NoClassDefFoundError: com/ibm/cognos/bux/service/atom/provider/cm/AtomUtils
com.ibm.cognos.bux.service.atom.provider.cm.providers.impl.contentmanager.DefaultAtomProvider.createSearchPath(DefaultAtomProvider.java:150)
com.ibm.cognos.bux.service.atom.provider.cm.providers.impl.contentmanager.DefaultAtomProvider.doGet(DefaultAtomProvider.java:185)
com.ibm.cognos.bux.service.atom.provider.cm.providers.BaseAtomProvider.handleRequest(BaseAtomProvider.java:52)
com.ibm.cognos.bux.service.atom.provider.cm.ContentManagerAtomProvider.handleRequest(ContentManagerAtomProvider.java:71)
com.ibm.cognos.bux.service.atom.ModelATOM.handleRequest(ModelATOM.java:232)
com.ibm.cognos.bux.service.atom.ViewATOM.handleRequest(ViewATOM.java:90)
com.ibm.cognos.bux.BUXControllerBaseImpl.mvcHandleRequest(BUXControllerBaseImpl.java:154)
com.ibm.cognos.bux.service.atom.AtomService.handleRequest(AtomService.java:55)
com.ibm.cognos.bux.http.ServiceRequestHelper._executeRequest(ServiceRequestHelper.java:80)
com.ibm.cognos.bux.http.ServiceRequestHelper.executeRequest(ServiceRequestHelper.java:50)
com.ibm.cognos.bux.service.main.ViewDHTMLInputStreamResolver$2.callImpl(ViewDHTMLInputStreamResolver.java:481)
com.ibm.cognos.bux.service.main.ViewDHTMLInputStreamResolver$2.callImpl(ViewDHTMLInputStreamResolver.java:1)
com.ibm.cognos.bux.service.main.BUXCallable.call(BUXCallable.java:34)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
  • 1
    Please add the stacktrace. – Jens Nov 12 '14 at 07:28
  • stacktrace added, thanks – mcfly soft Nov 12 '14 at 07:30
  • possible duplicate of [How to Solve java.lang.NoClassDefFoundError?](http://stackoverflow.com/questions/17973970/how-to-solve-java-lang-noclassdeffounderror) – Kick Buttowski Nov 12 '14 at 07:31
  • No I would say not. After a restart the class seams to be loaded, otherwise I could not execute my specific functionality after the restart. I am aware about the NoClassDefFoundError when the class is missing in the classpath and would not aks if thats the problem. – mcfly soft Nov 12 '14 at 07:37
  • Try referring this if that helps - http://javareferencegv.blogspot.com/2013/10/debugging-javalangnoclassdeffounderror.html – Crickcoder Nov 15 '14 at 09:02

3 Answers3

0

Clearly the Jar file containing the class com/ibm/cognos/bux/service/atom/provider/cm/AtomUtils is not present in the classpath and if present if not loaded by the Tomcat's class loader.

Mitesh Manani
  • 85
  • 1
  • 8
  • 1
    I clearly stated that after a restart it works fine. So it can't be that the class is missing in the classpath. I also would not ask this, because there are 1000 of answers for that kind of problems. – mcfly soft Nov 12 '14 at 07:36
0

Doesn't the classloader loads all classes at start ? - NO

Classes are loaded on demand. When AtomUtils class was required in DefaultAtomProvider.java ( line 150 ) it was not available.

What could be the reason ? - Most probably jar containing AtomUtils is missing.

Vipin
  • 4,851
  • 3
  • 35
  • 65
  • But then why it works after a startup. The class must be there, otherwise it would work never. – mcfly soft Nov 12 '14 at 07:44
  • Class was there at compile time so you were able to start application. But at runtime class jvm is not able to find class – Vipin Nov 12 '14 at 07:45
  • Important for you is "Classes are loaded on demand" , see some reasons behind this at http://mindprod.com/project/noclassdeffounderror.html – Vipin Nov 12 '14 at 07:46
0

Referring to Oracle NoClassDefFoundError Documentation:

NoClassDefFoundError is thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

The reason here depends on your build-path, maybe you have differents versions of the same jar file?

cнŝdk
  • 31,391
  • 7
  • 56
  • 78