Eclipse – I’m getting a noclassdeffounderror when trying to generate pojos or mapping with hibernate tools

code generationeclipsehibernatehibernate-toolspojo

I'm trying to generate pojos from my database but I get the following error(s) on eclipse indigo 3.7.2 with hibernate tools 3.4 plugin installed and hibernate 3.6.10 libraries (they seem to be all) in my build path

SHORT VERSION :

org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
  java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
  Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
    java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
    Could not initialize class org.hibernate.cfg.reveng.OverrideRepository

MY jars from the project buildpath are ( in order if that matters):

  • hibernate-distribution-3.6.10.Final\hibernate3.jar
  • hibernate-distribution-3.6.10.Final\lib\required\antlr-2.7.6.jar
  • hibernate-distribution-3.6.10.Final\lib\required\commons-collections-3.1.jar
  • hibernate-distribution-3.6.10.Final\lib\required\dom4j-1.6.1.jar
  • hibernate-distribution-3.6.10.Final\lib\required\javassist-3.12.0.GA.jar
  • hibernate-distribution-3.6.10.Final\lib\required\jta-1.1.jar
  • hibernate-distribution-3.6.10.Final\lib\required\slf4j-api-1.6.1.jar
  • postgresql-9.0-802.jdbc3.jar

I noticed that hibernate tools plugin has a few older jars in its plugins folder BTW( slf4j for example being version 1.5.8)
In the meantime I will try buddyloading

NORMAL STACKTRACE

ENTRY org.hibernate.eclipse.console 4 666 2012-06-25 04:23:55.946
!MESSAGE org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
!STACK 0
org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.launchExporters(ConsoleExtension3_6.java:149)
    at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:270)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6$3.execute(ConsoleExtension3_6.java:249)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.jboss.tools.hibernate3_6.HibernateExtension3_6.execute(HibernateExtension3_6.java:201)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.buildConfiguration(ConsoleExtension3_6.java:239)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.runExporters(ConsoleExtension3_6.java:169)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.launchExporters(ConsoleExtension3_6.java:126)
    ... 6 more
!SUBENTRY 1 org.hibernate.eclipse.console 4 666 2012-06-25 04:23:55.946
!MESSAGE org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
!STACK 0
org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.launchExporters(ConsoleExtension3_6.java:149)
    at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:270)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6$3.execute(ConsoleExtension3_6.java:249)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.jboss.tools.hibernate3_6.HibernateExtension3_6.execute(HibernateExtension3_6.java:201)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.buildConfiguration(ConsoleExtension3_6.java:239)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.runExporters(ConsoleExtension3_6.java:169)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.launchExporters(ConsoleExtension3_6.java:126)
    ... 6 more
!SUBENTRY 1 org.hibernate.eclipse.console 4 666 2012-06-25 04:23:55.946
!MESSAGE java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
!STACK 0
java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6$3.execute(ConsoleExtension3_6.java:249)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.jboss.tools.hibernate3_6.HibernateExtension3_6.execute(HibernateExtension3_6.java:201)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.buildConfiguration(ConsoleExtension3_6.java:239)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.runExporters(ConsoleExtension3_6.java:169)
    at org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.launchExporters(ConsoleExtension3_6.java:126)
    at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:270)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)  

The first time i tried to use code generation i got something like this :

org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class   java.lang.NoClassDefFoundError: org/objectweb/asm/Type   org/objectweb/asm/Type    
java.lang.NoClassDefFoundError: org/objectweb/asm/Type org/objectweb/asm/Type          
java.lang.ClassNotFoundException: org.objectweb.asm.Type     org.objectweb.asm.Type    

After that i got only the [...]cfg.reveng.OverrideRepository error.

Best Answer

After badly suffering with NoclassDefFoundError for Hours, I finally found the solution.

Main focus: The libraries of hibernate version should match with selected Hibernate version of console configuration(point 3).

Check List:

  1. Make sure you have downloaded latest version of Hibernate Plugin (That suits your eclipse's version). For getting it go to Help->Eclipse Marketplace-> type: hibernate (eclipse version name e.g. luna). Select Latest JBoss Tools and for minimum functionality select Hibernate and JBoss Maven Hibernate Configurator.

  2. Download latest jar files from http://hibernate.org/orm/downloads/. Store those files in folder that is there in your build path.

  3. When creating Hibernate console configuration make sure you select latest Hibernate Version from drop down. e.g. In my case as I had Hibernate 4.x jar file in build path, choosing version 4.3. solved problem.

Try changing Hibernate versions from drop down list of console configuration. It may fix the problem.

Related Topic