1 2 Previous Next 23 Replies Latest reply on Mar 27, 2013 12:06 PM by smarlow Go to original post
      • 15. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
        smarlow

        NoClassDefFoundError means that your web application tried to access the AccountManagement class, but the bytecode (definition) for AccountManagement couldn't be found from the web application.  Meaning, that the web application cannot get the DAO deployment to load (define) the AccountManagement class. 

         

        Another way might be to create a  module with your DAO jar in it.  Which should work if the DAO doesn't contain any classes that need to be deployed. 

        • 16. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
          glsilver

          Now I'm even more confused, and I wonder if there is anyone who has had a similar experience migrating from AS5 to AS7 using Hibernate 3.5 and has been able to work through it. If I include my org.hibernate:3 module as a direct dependency in my DAO library, adding it to MANIFEST.MF, even though it is included as a property in my persistence.xml, like so:

           

          <property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />

           

          I get the "No persistence provider" exception and a "Could not find any META-INF/persistence.xml file in the classpath" messages. Here's the exact log output:

           

          09:15:10,216 INFO  [org.hibernate.cfg.Environment] (http--127.0.0.1-8080-2) HHH000206: hibernate.properties not found

          09:15:10,218 INFO  [org.hibernate.cfg.Environment] (http--127.0.0.1-8080-2) HHH000021: Bytecode provider name : javassist

          09:15:10,228 INFO  [org.hibernate.ejb.Ejb3Configuration] (http--127.0.0.1-8080-2) HHH000318: Could not find any META-INF/persistence.xml file in the classpath

          09:15:10,230 INFO  [org.hibernate.ejb.Ejb3Configuration] (http--127.0.0.1-8080-2) Could not find any META-INF/persistence.xml file in the classpath

          09:15:10,232 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/WebPortal].[action]] (http--127.0.0.1-8080-2) Servlet.service() for servlet action threw exception: javax.persistence.

          PersistenceException: No Persistence provider for EntityManager named AccountManagement

                  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.dsi.objectmodel.persistence.PersistenceUnitBase.<clinit>(PersistenceUnitBase.java:37) [edispense.objectModel.core.jar:]

                  at com.dsi.evaccine.web.portal.struts.ShowLoginAction.getCopyright(ShowLoginAction.java:110) [classes:]

                  at com.dsi.evaccine.web.portal.struts.ShowLoginAction.execute(ShowLoginAction.java:97) [classes:]

                  at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) [struts-1.2.9.jar:1.2.9]

                  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) [struts-1.2.9.jar:1.2.9]

                  at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) [struts-1.2.9.jar:1.2.9]

                  at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) [struts-1.2.9.jar:1.2.9]

                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]

                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]

                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.14.Final.jar:]

                  at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.2.Final-SNAPSHOT.jar:7.1.2.Final-SNAPSHOT]

                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.14.Final.jar:]

                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.14.Final.jar:]

                  at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

           

          I don't think there is a classpath issue so much as a missing dependency somewhere in the Hibernate 3.5 setup as described in the documentation. This really shouldn't be this hard to fix. I am open to any suggestions.


          • 17. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
            smarlow

            Glenn,

             

            Do you want to try creating an AS7 module for your DAO jar and a dependency on that in your web app?  I wouldn't expect that to experience the no class def found problem when the web app tries to bring in the entity class definition (that we had with our earlier experiment).

             

            Scott

            • 18. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
              glsilver

              Scott,

               

              I created an AS7 module for my DAO jar and added a dependency to it in my web app (see module.xml, below), but got the exact same error message - No Persistence provider ...

              The main difficulty I am having in this is not seeing anything in the error logs to indicate what the exact problem might be...am I missing a dependency and if so which one(s). Trying to figure it out trial-and-error could take weeks.

              Jboss says all the modules and web apps load and so I assume all is well and everything should work when I run the application. What's even worse, loading a library as an AS7 module, instead of sticking it in the deployments directory, gives me even less of a clue as to what is happening. The logs don't say anything about loading modules. If there were an error and the module couldn't load, I wouldn't know about it until some other application that depends on it fails.

               

              I would really like to figure this out so I can do the migration from AS5, but, where do I even start?

               

              module.xml:

              <module xmlns="urn:jboss:module:1.1" name="com.dsi.objectmodel">

                  <resources>

                                       <resource-root path="edispense.objectModel.core.jar"/>

                  </resources>

                        <dependencies>

                            <module name="org.postgresql"/>

                            <module name="javax.persistence.api"/>

                   <module name="javax.api"/>

                   <module name="javax.xml.bind.api"/>

                </dependencies>

              </module>

              • 19. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
                smarlow

                Glenn,

                 

                Since that didn't just work, I think the best approach is to work towards an "upstream" (using latest Hibernate + AS7 sources) solution.  If your interested in pushing on that, I can suggest some initial steps.  Probably running the failing Hibernate 3.5.x code in a debugger and determining why this is failing would be a good next step.

                 

                Scott

                • 20. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
                  glsilver

                  Scott,

                   

                  Anything that will allow me to track down missing dependencies would be helpful. But I'm not sure the problem is in the persistence code. I ran tattle-tale on my DAO jar and here is the jboss-deployment-structure.xml it came up with:

                   

                  <?xml version="1.0"?>

                  <jboss-deployment-structure>

                    <deployment>

                       <dependencies>

                          <module name="javax.activation.api"/>

                          <module name="javax.mail.api"/>

                          <module name="javax.persistence.api"/>

                          <module name="javax.servlet.api"/>

                          <module name="javax.xml.bind.api"/>

                          <module name="org.dom4j"/>

                          <module name="org.hibernate"/>

                          <module name="org.jboss.as.web"/>

                          <module name="org.jboss.common-core"/>

                          <module name="org.jboss.logging"/>

                          <module name="system"/>

                       </dependencies>

                    </deployment>

                  </jboss-deployment-structure>

                   

                   

                  The library also has a dependency on org.apache.catalina.valves.ValveBase, which I found in catalina-6.0.16.jar, and that class apparently depends on javax.management.MBeanException, which is included in an old jboss-all-client-4.2.2.GA.jar. None of this relates specifically to persistence, nor does it prevent the library from loading. But apparently this prevents it from running.  So, as you can see, I may just have to start pulling the entire library apart and rewrite it to use "native" Hibernate 4 and AS7 dependencies. I don't see a way around this.

                  • 21. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
                    tviet

                    Hi Scott/Glenn

                     

                    Did you solve the issue? I'm migrating my app from jboss 4 to 7. FYI, I am using the hibernate 4 and I also faced with that kind of issue also.

                    I have package my apps to two separate packages, one is ear contains all EJB, MBean and JPA and the other is war. Now I faced with that issue on the war as you mentioned above. I noticed that the war recognized the DAO from ear but it could not find the persistence.xml. I did try to copy a copy of persistence to war/META-INF but it did not work, also on war/WEB-INF

                     

                    Do you have any advices on this?

                    Thanks in advances.

                    Viet Tran

                    • 22. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
                      glsilver

                      No. As far as I know this is not resolved.  I've long since migrated to an OSGi solution, which seems to have addressed this issue head on, with blueprint and spring dm.

                      • 23. Re: No persistence provider for EntityManager when using a shared Hibernate 3 module
                        smarlow

                        You might want to vote/watch AS7-1769, which is about sharing persistence units between separarate top level deployments. 

                        1 2 Previous Next