1 Reply Latest reply on Apr 18, 2012 12:46 PM by Srikrishna Kalavacharla

    Jboss 7.1.1.Final - Hibernate - How to Setup correctly?

    Srikrishna Kalavacharla Newbie

      We are migrating to 7.1.1.Final and trying to figure what's the right way to setup hibernate.  We have a Dynamic Web Project and we rely on JBoss Tools to build the war file.  We only have a WEB-INF/classes/hibernate.cfg.xml file which failed to load when I deployed the war file using admin console => Manage Deployments with "/hibernate.cfg.xml file not found".  I found in the 7.1 developer documentation that if there is a META-INF/persistence.xml file, it will automatically pull required libraries.  When I added a persistence.xml file, I do not get the "/hibernate.cfg.xml not found", but now I get a "java.lnag.NoClassDefFoundError: org/hibernate/HibernateException" error or "java.lang.NoClassDefFoundError: org/hibernate/jdbc/Work" error.  Next I'm going to try either shelving all the required libraries in WEB-INF/lib/ folder or add a jboss-deployment-structure.xml and see if it helps, but I'm curious what's the right approach here?  Is there a clean way to include hibernate?  I've attached my sample project I've created to demonstrate the problem as an attachment. We are using domain mode. Please review and let me know.

       

      Error in server logs -

       

      [Server:server-1] 09:56:17,959 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "J711H401.war"
      [Server:server-1] 09:56:18,416 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /J711H401
      [Server:server-1] 09:56:18,437 INFO  [org.jboss.as.server] (host-controller-connection-threads - 3) JBAS018559: Deployed "J711H401.war"
      [Server:server-1] 09:56:49,053 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/J711H401].[jsp]] (http--127.0.0.1-8180-1) Servlet.service() for servlet jsp threw exception: java.lang.ClassNotFoundException: org.hibernate.jdbc.Work from [Module "deployment.J711H401.war:main" from Service Module Loader]
      [Server:server-1]           at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      [Server:server-1]           at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
      [Server:server-1]           at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
      [Server:server-1]           at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      [Server:server-1]           at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
      [Server:server-1]           at com.j711h401.hibernate.test.TestHibernateDAO.<init>(TestHibernateDAO.java:19) [classes:]
      [Server:server-1]           at com.j711h401.hibernate.test.TestHibernateDAO.<clinit>(TestHibernateDAO.java:34) [classes:]
      [Server:server-1]           at org.apache.jsp.test_jsp._jspService(test_jsp.java:58)
      [Server:server-1]           at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
      [Server:server-1]           at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
      [Server:server-1]           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:67)
      [Server:server-1]           at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:48)
      [Server:server-1]           at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
      [Server:server-1]           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
      [Server:server-1]           at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0-ea]
      [Server:server-1] 
      
      

       

      Error in browser -

       

       

      HTTP Status 500 -
      
      type Exception report
      message
      description The server encountered an internal error () that prevented it from fulfilling this request.
      exception
      javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/hibernate/jdbc/Work org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791) org.apache.jsp.test_jsp._jspService(test_jsp.java:65) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 
      
      root cause
      java.lang.NoClassDefFoundError: org/hibernate/jdbc/Work com.j711h401.hibernate.test.TestHibernateDAO.<init>(TestHibernateDAO.java:19) com.j711h401.hibernate.test.TestHibernateDAO.<clinit>(TestHibernateDAO.java:34) org.apache.jsp.test_jsp._jspService(test_jsp.java:58) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 
      
      root cause
      java.lang.ClassNotFoundException: org.hibernate.jdbc.Work from [Module "deployment.J711H401.war:main" from Service Module Loader] org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) com.j711h401.hibernate.test.TestHibernateDAO.<init>(TestHibernateDAO.java:19) com.j711h401.hibernate.test.TestHibernateDAO.<clinit>(TestHibernateDAO.java:34) org.apache.jsp.test_jsp._jspService(test_jsp.java:58) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:847) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      
      

       

      Thanks

      Srikrishna Kalavacharla

        • 1. Re: Jboss 7.1.1.Final - Hibernate - How to Setup correctly?
          Srikrishna Kalavacharla Newbie

          I do not know if this is right way, but the minimum set of configuration worked for me is to add dependencies for hibernate in jboss-deployment-structure.xml as follows:

           

           

          <?xml version="1.0" encoding="UTF-8"?>
          <jboss-deployment-structure>
            <deployment>
              <dependencies>
                <module name="org.hibernate" />
                <module name="org.hibernate.envers" />
                <module name="org.hibernate.validator" />
              </dependencies>
              <resources>
                  <resource-root path="hibernate-core-4.0.1.Final.jar"/>
                  <resource-root path="hibernate-commons-annotations-4.0.1.Final.jar"/>
                  <resource-root path="hibernate-entitymanager-4.0.1.Final.jar"/>
                  <resource-root path="hibernate-infinispan-4.0.1.Final.jar"/>
                  <resource-root path="hibernate-envers-4.0.1.Final.jar"/>
                        <resource-root path="hibernate-validator-4.2.0.Final.jar"/>
              </resources>
             </deployment>
          </jboss-deployment-structure>
          
          
          

           

           

          Attached my working sample as well. 

           

          Thanks

          Srikrishna Kalavacharla

          1 of 1 people found this helpful