5 Replies Latest reply on Apr 6, 2009 11:53 AM by gbadavidson

    Hibernate + JBoss problem

    dabubble

      Hi all!

      I'm trying to use a prepackaged persistence layer with a Web deployment in a small tutorial.

      So the main war has a jar with the persistence layer.

      The LibraryPersistence is has follows (works fine outside of JBoss)

      librarypersistence.jar:

      >library. (...) < all the hibernate files
      >hibernate.cfg.xml

      The content of hibernate.cfg.xml is:

      <hibernate-configuration>
      
      <session-factory>
       <!-- properties -->
       <property name="connection.username">root</property>
       <property name="connection.url">jdbc:mysql://localhost:3306/test</property>
       <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
       <property name="connection.password"></property>
       <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
      
       <!-- mapping files -->
       <property name="myeclipse.connection.profile">MySQL Test Database</property><mapping resource="library/persistence/layer/Book.hbm.xml" /><mapping resource="library/persistence/layer/Customer.hbm.xml" />
      
      </session-factory>
      
      </hibernate-configuration>
      


      The main web deplyment has the following structure:

      LibraryWeb.war:

      >WEB-INF
      >lib
      >mysql-connector.....jar
      >ehcache.....jar
      >librarypersistence.jar
      >...
      ... (all the files relative to the web part)


      ________________

      At first it kept giving me error that it couldn't find the hibernate.cfg.xml file so I copyed it to the WEB-INF>classes dir wich worked but this solution doesn't work well form me has I'm trying to decople completely the persistence layer.

      Now it keeps giving me errors tha it cant find the driver (com.mysql.jdbc.Driver) wich is directly in the lib dir and also it can't find a ehcache exception.

      The full stack trace is:

      14:51:40,109 INFO [Environment] Hibernate 3.1 beta 2
      14:51:40,119 INFO [Environment] hibernate.properties not found
      14:51:40,119 INFO [Environment] using CGLIB reflection optimizer
      14:51:40,119 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
      14:51:40,310 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
      14:51:40,310 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
      14:51:48,321 INFO [Configuration] Reading mappings from resource: library/persistence/layer/Book.hbm.xml
      14:51:48,491 INFO [HbmBinder] Mapping class: library.persistence.layer.Book -> book
      14:51:48,712 INFO [Configuration] Reading mappings from resource: library/persistence/layer/Customer.hbm.xml
      14:51:48,742 INFO [HbmBinder] Mapping class: library.persistence.layer.Customer -> customer
      14:51:48,752 INFO [Configuration] Configured SessionFactory: null
      14:51:48,752 INFO [Configuration] processing extends queue
      14:51:48,752 INFO [Configuration] processing collection mappings
      14:51:48,752 INFO [HbmBinder] Mapping collection: library.persistence.layer.Customer.bookSet -> book
      14:51:48,782 INFO [Configuration] processing association property references
      14:51:48,782 INFO [Configuration] processing foreign key constraints
      14:51:48,812 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
      14:51:48,812 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20
      14:51:48,812 INFO [DriverManagerConnectionProvider] autocommit mode: false
      14:51:48,862 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/test
      14:51:48,872 INFO [DriverManagerConnectionProvider] connection properties: {user=root, password=}
      14:51:48,872 WARN [SettingsFactory] Could not obtain connection metadata
      java.sql.SQLException: No suitable driver
       at java.sql.DriverManager.getConnection(DriverManager.java:545)
       at java.sql.DriverManager.getConnection(DriverManager.java:140)
       at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1502)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1031)
       at library.persistence.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:58)
       at library.businesslogic.LibraryManager.getAllBooks(LibraryManager.java:40)
       at library.struts.action.BookListAction.execute(BookListAction.java:31)
       at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
       at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
       at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
       at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      14:51:48,942 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
      14:51:48,962 INFO [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
      14:51:48,962 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
      14:51:48,962 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
      14:51:48,962 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
      14:51:48,972 INFO [SettingsFactory] Scrollable result sets: disabled
      14:51:48,972 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
      14:51:48,972 INFO [SettingsFactory] Connection release mode: null
      14:51:48,972 INFO [SettingsFactory] Maximum outer join fetch depth: 2
      14:51:48,972 INFO [SettingsFactory] Default batch fetch size: 1
      14:51:48,972 INFO [SettingsFactory] Generate SQL with comments: disabled
      14:51:48,972 INFO [SettingsFactory] Order SQL updates by primary key: disabled
      14:51:48,972 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
      14:51:48,982 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
      14:51:48,982 INFO [SettingsFactory] Query language substitutions: {}
      14:51:48,982 INFO [SettingsFactory] Second-level cache: enabled
      14:51:48,982 INFO [SettingsFactory] Query cache: disabled
      14:51:48,982 INFO [SettingsFactory] Cache provider: org.hibernate.cache.EhCacheProvider
      14:51:49,082 ERROR [[action]] Servlet.service() for servlet action threw exception
      java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
       at java.lang.Class.getDeclaredConstructors0(Native Method)
       at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
       at java.lang.Class.getConstructor0(Class.java:2640)
       at java.lang.Class.newInstance0(Class.java:321)
       at java.lang.Class.newInstance(Class.java:303)
       at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:326)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1502)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1031)
       at library.persistence.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:58)
       at library.businesslogic.LibraryManager.getAllBooks(LibraryManager.java:40)
       at library.struts.action.BookListAction.execute(BookListAction.java:31)
       at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
       at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
       at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
       at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      14:52:36,931 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://localhost:3306/test
      


      Anyone can help plz?

      Thanks in advance.

        • 1. Re: Hibernate + JBoss problem
          dabubble

          Btw I hope you can get a clear idea of the structure because the forum eliminated all the suplus spaces behind the >.

          • 2. Re: Hibernate + JBoss problem
            tran0261

            Try to put the mysql driver in tomcat/common/lib also. Hope it works

            • 3. Re: Hibernate + JBoss problem
              gbadavidson

              I am having the same problem here is the section from the console and I willfollow that with the hibernate config file. It appears from the console output that the correct driver is in fact found. It also appears that the metadata is not being read yet I see the metatdata being displayed.
              Please note that I am able to access the database in both the database and hibernate perspectives. Please any help here will be greatly appreciated.

              Thanks
              Glenn

              .......
              15:35:09,234 INFO [Environment] Hibernate 3.2.4.sp1.cp06
              15:35:09,235 INFO [Environment] hibernate.properties not found
              15:35:09,235 INFO [Environment] Bytecode provider name : javassist
              15:35:09,266 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
              15:35:09,453 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
              15:35:09,453 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
              15:35:09,609 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Phone.hbm.xml
              15:35:09,765 INFO [HbmBinder] Mapping class: person.Phone -> phone
              15:35:09,812 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Personrolexref.hbm.xml
              15:35:09,828 INFO [HbmBinder] Mapping class: person.Personrolexref -> personrolexref
              15:35:09,828 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Personaddressxref.hbm.xml
              15:35:09,843 INFO [HbmBinder] Mapping class: person.Personaddressxref -> personaddressxref
              15:35:09,843 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Role.hbm.xml
              15:35:09,843 INFO [HbmBinder] Mapping class: person.Role -> role
              15:35:09,843 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Person.hbm.xml
              15:35:09,859 INFO [HbmBinder] Mapping class: person.Person -> person
              15:35:09,859 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Address.hbm.xml
              15:35:09,859 INFO [HbmBinder] Mapping class: person.Address -> address
              15:35:09,859 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Personcoursexref.hbm.xml
              15:35:09,875 INFO [HbmBinder] Mapping class: person.Personcoursexref -> personcoursexref
              15:35:09,875 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/person/Personphonexref.hbm.xml
              15:35:09,875 INFO [HbmBinder] Mapping class: person.Personphonexref -> personphonexref
              15:35:09,890 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Coursecategoryxref.hbm.xml
              15:35:09,890 INFO [HbmBinder] Mapping class: course.Coursecategoryxref -> coursecategoryxref
              15:35:09,890 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Course.hbm.xml
              15:35:09,906 INFO [HbmBinder] Mapping class: course.Course -> course
              15:35:09,906 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Courseprogresshistory.hbm.xml
              15:35:09,921 INFO [HbmBinder] Mapping class: course.Courseprogresshistory -> courseprogresshistory
              15:35:09,921 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Category.hbm.xml
              15:35:09,921 INFO [HbmBinder] Mapping class: course.Category -> category
              15:35:09,921 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Visibility.hbm.xml
              15:35:09,937 INFO [HbmBinder] Mapping class: course.Visibility -> visibility
              15:35:09,937 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Slide.hbm.xml
              15:35:09,937 INFO [HbmBinder] Mapping class: course.Slide -> slide
              15:35:09,937 INFO [Configuration] Reading mappings from resource : com/bellecrestsoftware/course/Rating.hbm.xml
              15:35:09,953 INFO [HbmBinder] Mapping class: course.Rating -> rating
              15:35:09,953 INFO [Configuration] Configured SessionFactory: null
              15:35:16,224 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
              15:35:16,224 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20
              15:35:16,224 INFO [DriverManagerConnectionProvider] autocommit mode: false
              15:35:16,225 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/MiracleMind
              15:35:16,225 INFO [DriverManagerConnectionProvider] connection properties: {user=root, password=root}
              15:35:16,225 WARN [SettingsFactory] Could not obtain connection metadata
              java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/MiracleMind
              at java.sql.DriverManager.getConnection(Unknown Source)
              at java.sql.DriverManager.getConnection(Unknown Source)
              at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
              at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
              at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2063)
              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
              at com.bellecrestsoftware.hibernate.HibernateSessionFactory.(HibernateSessionFactory.java:31)
              at com.bellecrestsoftware.hibernate.BaseHibernateDAO.getSession(BaseHibernateDAO.java:13)
              ...........

              The hibernate config file is:
              <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
              "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

              <!-- Generated by MyEclipse Hibernate Tools. -->
              <hibernate-configuration>

              <session-factory>
              org.gjt.mm.mysql.Driver
              root

              jdbc:mysql://localhost:3306/MiracleMind


              org.hibernate.dialect.MySQLDialect


              New MySQL

              update
              root

              com.mysql.jdbc.Driver


















              </session-factory>

              </hibernate-configuration>

              • 4. Re: Hibernate + JBoss problem
                peterj

                gbadavidson, please do not ask new questions on posts that are 3-1/2 years old. You should ask this question in a new post, and use the "code" tags when posting XML text.

                • 5. Re: Hibernate + JBoss problem
                  gbadavidson

                  Peter,
                  I am sorry that I didn't look at how old the post was. I tried to find the solution to my question first without having to post. This was the only post I could find that was similar.