java.lang.NoClassDefFoundError:org / hibernate / cfg / Configuration [英] java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

查看:208
本文介绍了java.lang.NoClassDefFoundError:org / hibernate / cfg / Configuration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我遇到以下问题:

  java.lang.ClassNotFoundException:org.hibernate.cfg.Configuration 
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: 1701)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
db.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
db.HibernateUtil。<临床>(HibernateUtil.java:8)

我已经在线看了我的问题,我明白有一些东西要与项目类路径。



我已经在我的项目中添加了一个用户库,其中包含hibernate下载中必需目录下的所有jar,但是这似乎不起作用。



请找到我的项目的屏幕截图这里:

解决方案

你收到错误是因为hibernate库不可用于Tomcat 。在你的照片中,在hibernate库集下面有一个名为'Web App Libraries'的空集 - 这是您的hibernate库所需要的。



右键单击您的项目 - >构建路径 - >配置构建路径,并从构建路径中删除hibernate集。现在将jar导入WEB-INF / lib文件夹。刷新您的项目,现在您应该看到它们列在Web应用程序库集中(我感到这有点烦人,你必须将它们导入代码库 - 有人可能会知道一个更好的方法来做到这一点,涉及复制瓶子)


I'm trying to do an initial setup with Hibernate in Eclipse, while deploying with Tomcat.

I encountered the following problem:

java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
    db.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
    db.HibernateUtil.<clinit>(HibernateUtil.java:8)

I've goggled my problem online and I understand that it has something to to with the project class path.

I've added a user library to my project containing all the jars under the "required" directory in the hibernate download, but that doesn't seem to work.

Please find a screen shot of my project here:

解决方案

You're getting the error because the hibernate libraries are not available to Tomcat. In your picture, below the hibernate library set there is an empty set called 'Web App Libraries' - this is the set your hibernate libraries need to be in.

Right click your project -> Build Path -> Configure Build Path, and remove the hibernate set from the build path. Now import the jars into the WEB-INF/lib folder. Refresh your project and now you should see them listed in the 'Web App Libraries' set (i appreciate this is somewhat annoying that you have to import them into your code base - someone else might know a better way to do this that doesn't involve copying the jars in)

这篇关于java.lang.NoClassDefFoundError:org / hibernate / cfg / Configuration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆