4

我正在尝试从我的数据库中生成 pojos,但是在我的构建路径中安装了休眠工具 3.4 插件和休眠 3.6.10 库(它们似乎全部)的 eclipse indigo 3.7.2 上出现以下错误

精简版 :

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

来自项目构建路径的我的罐子是(如果重要的话,按顺序):

  • 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

我注意到休眠工具插件在其插件文件夹中有一些较旧的 jar 顺便说一句(例如 slf4j 是 1.5.8 版)同时我会尝试 buddyloading

正常堆栈跟踪

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)  

我第一次尝试使用代码生成时,我得到了这样的结果:

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    

之后我只得到了[...]cfg.reveng.OverrideRepository error.

4

3 回答 3

6

在遭受 NoclassDefFoundError 数小时的严重折磨后,我终于找到了解决方案。

重点:hibernate 版本的库应与控制台配置的选定 Hibernate 版本匹配(第 3 点)。

检查清单:

  1. 确保您已下载最新版本的 Hibernate 插件(适合您的 Eclipse 版本)。要获得它,请转到 Help->Eclipse Marketplace-> 输入:hibernate(eclipse 版本名称,例如 luna)。选择最新的 JBoss 工具,并选择 Hibernate 和 JBoss Maven Hibernate Configurator 以获得最低功能。

  2. 从http://hibernate.org/orm/downloads/下载最新的 jar 文件。将这些文件存储在构建路径中的文件夹中。

  3. 创建 Hibernate 控制台配置时,请确保从下拉列表中选择最新的 Hibernate 版本。例如,在我的情况下,我在构建路径中有 Hibernate 4.x jar 文件,选择版本 4.3。解决了问题。

尝试从控制台配置的下拉列表中更改 Hibernate 版本。它可能会解决问题。

于 2014-09-28T12:44:24.940 回答
3

正确答案:https
://community.jboss.org/thread/201634?tstart=0 如果有人有什么要补充的,请花点时间去做,就像我一样。

谢谢

顺便说一句,我不敢相信社区中的任何人都遇到过这个错误/问题

于 2012-06-26T16:20:12.937 回答
-2

我在进行hibernate逆向工程时也遇到了这个问题,我经历了将近3天,但我终于得到了解决方案。

  1. 为了进行hibernate逆向工程,您不需要显式添加任何与hibernate相关的jar,因为它与hibernate工具插件一起提供,唯一的问题是您必须为相应的数据库添加jdbc jar。

  2. 创建项目后,您在 Eclipse 的角度选择休眠选项,然后您将选择File => New =>Hibernate Console Configuration

  3. 在这里,您必须进行休眠控制台配置,因为您有“休眠版本”确保您在此处选择的版本与您在创建休眠配置文件时必须选择的版本相同,如果您愿意的话,它只不过是hibernate.cfg.xml同样你不会得到这个错误:

org.hibernate.console.HibernateConsoleRuntimeException: 收到 NoClassDefFoundError,可能控制台配置类路径不完整或包含同一类的冲突版本

于 2017-05-24T07:19:23.473 回答