4 Replies Latest reply on Oct 17, 2011 5:03 PM by Red Militante

    JBoss AS 7.0.1 -  javax.persistence.PersistenceException: No Persistence provider for EntityManager

    Red Militante Newbie

      My hibernate app was running successfully in jboss-as-7.0.0.Final, I moved it to jboss-as-7.0.1.Final and I started receiving these errors

       

       

          17:42:42,725 ERROR [com.mycompany.myapp.common.persistence.HibernateUtil] (MSC service thread 1-12) Initial SessionFactory lookup failed.: javax.persistence.PersistenceException: No Persistence provider for EntityManager named primary
                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
                at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
                at com.mycompany.myapp.common.persistence.HibernateUtil.<clinit>(HibernateUtil.java:35) [classes:]
                at com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:84) [classes:]
                at com.mycompany.myapp.common.jms.JMSListenerServletTemplate.init(JMSListenerServletTemplate.java:41) [classes:]
                at com.mycompany.myapp.common.jms.JMSAnywhereServlet.init(JMSAnywhereServlet.java:179) [classes:]
                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3844) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
                at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
                at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
      
      
          17:42:42,732 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp]] (MSC service thread 1-12) StandardWrapper.Throwable: java.lang.NoClassDefFoundError: Could not initialize class com.mycompany.myapp.common.persistence.HibernateUtil
                at com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:92) [classes:]
                at com.mycompany.myapp.common.jms.JMSListenerServletTemplate.init(JMSListenerServletTemplate.java:41) [classes:]
                at com.mycompany.myapp.common.jms.JMSAnywhereServlet.init(JMSAnywhereServlet.java:179) [classes:]
                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3844) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
                at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
                at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
      
      
          17:42:42,734 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myapp]] (MSC service thread 1-12) Servlet /myapp threw load() exception: java.lang.NoClassDefFoundError: Could not initialize class com.mycompany.myapp.common.persistence.HibernateUtil
                at com.mycompany.myapp.common.businessobjects.ServerSettings.GetServerSettings(ServerSettings.java:92) [classes:]
                at com.mycompany.myapp.common.jms.JMSListenerServletTemplate.init(JMSListenerServletTemplate.java:41) [classes:]
                at com.mycompany.myapp.common.jms.JMSAnywhereServlet.init(JMSAnywhereServlet.java:179) [classes:]
                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3631) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3844) [jbossweb-7.0.1.Final.jar:7.0.1.Final]
                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) [jboss-as-web-7.0.1.Final.jar:7.0.1.Final]
                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
                at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
                at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
      
      
      

      my persistence.xml looks like

       

       

          <?xml version="1.0" encoding="UTF-8"?>
          <persistence version="2.0"
             xmlns="http://java.sun.com/xml/ns/persistence"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
              http://java.sun.com/xml/ns/persistence
              http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
             <persistence-unit name="primary">
            <non-jta-data-source>java:jboss/datasources/MySqlDS</non-jta-data-source>
      
      
            <properties>
      
      
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
               <property name="hibernate.ejb.interceptor.session_scoped" value="com.clairvista.liveexpert.common.persistence.BusinessObjectInterceptor"/>
                     </properties>
         </persistence-unit>
      </persistence>
      
      

      and my pom.xml looks like

       

       

                  <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-core</artifactId>
                      <version>4.0.0.Beta5</version>
            </dependency>
      
      
            <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-commons-annotations</artifactId>
                      <version>3.2.0.Final</version>
            </dependency>
            <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-entitymanager</artifactId>
                      <version>4.0.0.Beta5</version>
            </dependency>
      
      
            <dependency>
                      <groupId>org.hibernate</groupId>
                      <artifactId>hibernate-infinispan</artifactId>
                      <version>4.0.0.Beta5</version>
            </dependency>
      
      

      the code that throws these errors looks like

       

       

                        entityManagerFactory = Persistence.createEntityManagerFactory("primary");
      
      

      I'm not sure what's going on - this app was working in jboss-as-7.0.0.Final.  I know 7.0.1 has better support for hibernate versions bundled within applications - but I'm not sure how this relates to my problem as I'd like to use the version of hibernate that comes bundled with the container.  Any ideas?