java.lang.NoClassDefFoundError:org/hibernate/Session hibernate jars已设置
在我的新工作中,我继承了几个Java项目,但是我在设置方面遇到了一些问题。我面临着一个非常普遍的问题。NoClassDefFoundError:org/hibernate/Session,将所有JAR(甚至不必要的hibernate)映射到类路径中 我正在使用Tomcat7、Hirbernat4和jre7 每个项目都扩展了compnet,在lib文件夹中有所有必要的jar 我需要把那些已经映射的JAR放在这个项目中吗 错误在于:java.lang.NoClassDefFoundError:org/hibernate/Session hibernate jars已设置,java,hibernate,tomcat,servlets,Java,Hibernate,Tomcat,Servlets,在我的新工作中,我继承了几个Java项目,但是我在设置方面遇到了一些问题。我面临着一个非常普遍的问题。NoClassDefFoundError:org/hibernate/Session,将所有JAR(甚至不必要的hibernate)映射到类路径中 我正在使用Tomcat7、Hirbernat4和jre7 每个项目都扩展了compnet,在lib文件夹中有所有必要的jar 我需要把那些已经映射的JAR放在这个项目中吗 错误在于: @Override public void init(Se
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
HibernateUtil.currentSession();
}
类路径:
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/xstream 1.3/xpp3_min-1.1.4c.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/xstream 1.3/xstream-1.3.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/commons fileupload 1.2.1/commons-fileupload-1.2.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/antlr.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/commons-collections.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/dom4j.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/ejb3-persistence.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/hibernate-annotations.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/hibernate-commons-annotations.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/hibernate-validator.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/hibernate3.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/javassist.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/jta.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/jtds-1.2.4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/log4j.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/slf4j-api.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/hibernate 3/slf4j-log4j12.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/commons logging/commons-logging-1.1.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/commons logging/commons-logging-adapters-1.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/commons logging/commons-logging-api-1.1.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/pkg_ocorrencia"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/pkg_mandado"/>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/commons-beanutils-1.8.2.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/commons-digester-1.7.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/groovy-all-1.5.5.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/iText-2.1.0.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/jasperreports-3.7.4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/jasperreports-chart-themes-3.7.4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/jasperreports-extensions-3.5.3.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/jasperreports-fonts-3.7.4.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/spring.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/xalan.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/jfreechart-1.0.12.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/jasper - ireport 3.7.4/jcommon-1.0.15.jar">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/Compnet"/>
<classpathentry exported="true" kind="lib" path="/Compnet/lib/commons email 1.2/commons-email-1.2.jar"/>
<classpathentry kind="lib" path="D:/Tomcat 7/apache-tomcat-7.0.27/lib/servlet-api.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/antlr-2.7.7.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/c3p0-0.9.1.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/ehcache-core-2.4.3.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-c3p0-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-commons-annotations-4.0.1.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-core-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-ehcache-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-entitymanager-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-envers-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-infinispan-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/hibernate-proxool-4.1.4.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/infinispan-core-5.1.4.FINAL.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/javassist-3.15.0-GA.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/jboss-logging-3.1.0.GA.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/jboss-marshalling-1.3.11.GA.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/jboss-marshalling-river-1.3.11.GA.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/jboss-transaction-api_1.1_spec-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/jgroups-3.0.9.Final.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/proxool-0.8.3.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/rhq-pluginAnnotations-3.0.4.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/slf4j-api-1.6.1.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/stax2-api-3.1.1.jar"/>
<classpathentry kind="lib" path="/Compnet/lib/hibernate4/woodstox-core-asl-4.1.1.jar"/>
<classpathentry kind="output" path="build/classes"/>
stacktrance:
java.lang.NoClassDefFoundError:org/hibernate/Session
在br.com.flex4j.servlet.genericActionServlet.initgenericActionServlet.java:29
位于org.apache.catalina.core.StandardWrapper.loadServletStandardWrapper.java:1161
位于org.apache.catalina.core.StandardWrapper.allocateStandardWrapper.java:806
位于org.apache.catalina.core.StandardWrapperValve.invokeStandardWrapperValve.java:129
位于org.apache.catalina.core.StandardContextValve.invokeStandardContextValve.java:175
位于org.apache.catalina.core.StandardHostValve.invokeStandardHostValve.java:128
位于org.apache.catalina.valves.ErrorReportValve.invokeErrorReportValve.java:102
位于org.apache.catalina.core.StandardEngineValve.InvokeStandardenginievalve.java:109
位于org.apache.catalina.connector.CoyoteAdapter.serviceCoyoteAdapter.java:263
位于org.apache.coyote.http11.Http11Processor.processHttp11Processor.java:844
位于org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processHttp11Protocol.java:584
位于org.apache.tomcat.util.net.JIoEndpoint$Worker.runJIoEndpoint.java:447
位于java.lang.Thread.runUnknown Source
原因:java.lang.ClassNotFoundException:org.hibernate.Session
位于org.apache.catalina.loader.WebappClassLoader.loadClassWebappClassLoader.java:1358
位于org.apache.catalina.loader.WebappClassLoader.loadClassWebappClassLoader.java:1204
... 还有13个
2012年6月21日下午3:39:22 org.apache.catalina.core.StandardWrapper
严重:为servlet genericActionServlet分配异常
java.lang.ClassNotFoundException:org.hibernate.Session
位于org.apache.catalina.loader.WebappClassLoader.loadClassWebappClassLoader.java:1358
位于org.apache.catalina.loader.WebappClassLoader.loadClassWebappClassLoader.java:1204
在br.com.flex4j.servlet.genericActionServlet.initgenericActionServlet.java:29
位于org.apache.catalina.core.StandardWrapper.loadServletStandardWrapper.java:1161
位于org.apache.catalina.core.StandardWrapper.allocateStandardWrapper.java:806
位于org.apache.catalina.core.StandardWrapperValve.invokeStandardWrapperValve.java:129
位于org.apache.catalina.core.StandardContextValve.invokeStandardContextValve.java:175
位于org.apache.catalina.core.StandardHostValve.invokeStandardHostValve.java:128
位于org.apache.catalina.valves.ErrorReportValve.invokeErrorReportValve.java:102
位于org.apache.catalina.core.StandardEngineValve.InvokeStandardenginievalve.java:109
位于org.apache.catalina.connector.CoyoteAdapter.serviceCoyoteAdapter.java:263
位于org.apache.coyote.http11.Http11Processor.processHttp11Processor.java:844
位于org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processHttp11Protocol.java:584
位于org.apache.tomcat.util.net.JIoEndpoint$Worker.runJIoEndpoint.java:447
位于java.lang.Thread.runUnknown Source
编辑:
我的项目的类路径:java构建路径>据我所知,Eclipse使用您提供的类路径xml,它与您的web应用程序类路径无关。出现NoClassDefFoundError的原因是Tomcat无法找到Hibernate类。确保您的Web模块在Web-INF/lib目录中具有所有必需的JAR。将所有JAR添加到Web-INF并在project上执行生成路径。要在eclipse中添加JAR,您有两个选项: 右键单击project got to 属性->单击java构建路径->配置构建路径->库-> 然后选择Addexternaljars按钮。它将打开一个窗口,您可以在其中添加所需的所有jar 第二个选项是将jar直接粘贴到lib文件夹。库文件夹位于Web内容->Web-INF->库中
使用其中任何一个。@MalGaniS您的Eclipse项目类路径与tomcat初始化应用程序时使用的类路径无关。如果要从Eclipse启动Tomcat,必须将jar文件复制到Webcontent/WEB-INF文件夹。我相信有一些构建脚本ANT将所有依赖项复制到war文件的WEB-INF/lib文件夹中。。我需要把这些库放在我的tomcat库文件夹中。。3年的.NET工作让我忘记了这一点。。谢谢