java.lang.NoClassDefFoundError

1

Does anyone know how to solve the exception java.lang.NoClassDefFoundError? I understand that it occurs when you can not find the class in the classpath, or am I wrong? The strange thing is that I found it without problem and from one day to the next I stopped doing it. The classes you do not find is from a project called Trdiario , which generated the jar and placed it at this address: C: \ Company \ lib , along with other auxiliary libraries . I add to a project called Development, a new library, adding all the jars of the folder C: \ Company \ lib with add Library and as IDE I use Eclipse.
It should be noted that only the classes of the Trdiario.jar jar do not recognize me.
I would appreciate if someone can guide me to solve the conflict.
This is the trace of the error:

java.lang.NoClassDefFoundError: TotClt
    at com.TrDiario.TotCltC.ejecutarTotClt(TotCltW.cbl:400)
    at com.Riesgo.VerCategoriaJNDI.CargarDatos(VerCategoriaJNDI.java:559)
    at com.Riesgo.VerCategoriaJNDI$3.actionPerformed(VerCategoriaJNDI.java:143)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: TotClt
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 39 more



When I generate the jar of the Trdiario project, this warning appears:

JAR export finished with warnings. See details for additional information.
  Could not find source file attribute for: 'C:\Users\User\desarrolloCD\Trdiario99\bin\com\TrDiario\PorSucursalC2$_MF_LCTYPE_1.class'
  Source name not found in a class file - exported all class files in Trdiario99/bin/com/TrDiario
    
asked by Carlos 04.04.2017 в 15:03
source

2 answers

3

NoClassDefFoundError is thrown when the virtual machine tries to load a class to execute a method or create an instance and does not find the class in question. This class was present when compiling. That is, it is an error of runtime .

Examine the error trace, which will indicate a specific class, and check that the related libraries are present at runtime. There is a library with which you compile your project Informes that you will also have to copy to C:\Empresa\lib.

    
answered by 04.04.2017 / 15:23
source
0

It could also be because of the compiler versions of the .class that it does not recognize.

If the .class is more advanced (eg 1.8) than the JRE that will execute it (eg 1.7) then it does not load it.

Does it appear somewhere in the exception this: "major version" or "minor version"?

    
answered by 04.04.2017 в 15:12