简体   繁体   中英

java.lang.NoClassDefFoundError: org/hibernate/MappingException

I am getting the following error while starting my Apache Tomcat server. I have integrated Struts with Hibernate framework.

Could anyone tell me reason for this exception?

PFA exception logs coming while starting the server?

Feb 11, 2014 10:46:09 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\eclipse-standard-kepler-R-win32\eclipse;;.
Feb 11, 2014 10:46:09 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsOne' did not find a matching property.
Feb 11, 2014 10:46:09 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Feb 11, 2014 10:46:09 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 766 ms
Feb 11, 2014 10:46:09 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 11, 2014 10:46:09 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
Feb 11, 2014 10:46:10 AM org.apache.struts.action.ActionServlet initChain
INFO: Loading chain catalog from jar:file:/C:/Users/Mohit/workspace/Struts/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsOne/WEB-INF/lib/struts-core-1.3.10.jar!/org/apache/struts/chain/chain-config.xml
Feb 11, 2014 10:46:10 AM org.apache.struts.action.ActionServlet init
SEVERE: Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable.  Most likely, this is due to an incorrect or missing library dependency.
java.lang.NoClassDefFoundError: org/hibernate/MappingException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:172)
    at org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:147)
    at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:842)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4420)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4733)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
    at org.apache.catalina.core.StandardService.start(StandardService.java:525)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: org.hibernate.MappingException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
    ... 27 more

if you're working in eclipse, you should add the hibernate jars in your web project classpath and deploy assembly.

do that by right clicking on project -> properties -> deploy assembly, and add the jars. or (if jars are in the WEB-INF/lib folder) right click on project -> properties -> java build path -> select "libraries" tab, then add library, and select weba bb libraries

You were asking the reason for this exception.

Please see what the log tell us,

"Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency"

When you start your server, where your application has already been deployed either manually by dropping the war file, or by working through eclipse, the first entry point to your application is the deployment descriptor , that is web.xml . Here you have defined your servlet as Struts Action Servlet, so an attempt will be made to initialize Struts ActionServlet.

Now, inside your struts-config.xml, you might have something like this,

<struts-config>
....
    <plug-in className="com.example.MyHibernatePlugin">
        <set-property property="path" value="/hibernate.cfg.xml"/>
    </plug-in>
....
<struts-config>

com.example MyHibernatePlugin.java

import org.apache.struts.action.PlugIn;
public class HibernatePlugin implements PlugIn { ....{your code} }

Having said this, now your logs are trying to say something, of why it is getting a mapping exception while trying to initialize Struts Action Servlet.

You must have all libraries related to Struts and Hibernate in your classpath . Do not add all at once, Add one by one, see which jar it is complaining of, and then add until it stops complaining.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM