11 Replies Latest reply on Dec 4, 2007 5:07 AM by wolfc

    New persistence unit deployers

    wolfc

      I'm creating a new set of persistence unit deployers. Currently persistence units outside of an EJB 3 deployment scope are not functioning. Might as well do it the right way instead of hacking the Ejb3Deployer.

      So I'm now starting on the PersistenceUnitParsingDeployer.

      http://jira.jboss.com/jira/browse/EJBTHREE-1138

        • 1. Re: New persistence unit deployers
          wolfc

          The PersistenceUnitParsingDeployer is now creating a PersistenceUnitsMetaData. For the moment the Ejb3Deployer picks it up (instead of xml) and goes through the motions.

          Issues:
          - hack in PersistenceUnitParsingDeployer for wars (maybe Adrian can take a look?)
          - how do I determine by the book whether the deployment is a library of an EAR? (For scoping)

          Blocker:
          - the class loader is giving me issues, it wants to load entities named WEB-INF.classes.org.jboss.SomeEntity (need help here)

          ToDo:
          - jank it out of Ejb3Deployer

          • 2. Re: New persistence unit deployers
            starksm64

            Why is the WEB-INF/classes/META-INF/persistence.xml needed? Is this just what you had to use to find the WEB-INF/classes/persistence.xml descriptor? I need to see an example war. I'll see if I can find one in the ejb3 testsuite.

            Deployment scoping should be determined by the class loader import/export policy under the new class loader. What is this comment about?
            // FIXME: if in EAR then unscoped else scoped

            An ear lib is not identified specially other than a deployment unit with an org.jboss.metadata.ear.spec.Ear5xMetaData attachment(type will be EarMetaData in terms of getting the attachment) with a libraryDirectory for which a VirtualFile exists.


            • 3. Re: New persistence unit deployers
              wolfc

               

              "scott.stark@jboss.org" wrote:
              Deployment scoping should be determined by the class loader import/export policy under the new class loader. What is this comment about?
              // FIXME: if in EAR then unscoped else scoped

              An ear lib is not identified specially other than a deployment unit with an org.jboss.metadata.ear.spec.Ear5xMetaData attachment(type will be EarMetaData in terms of getting the attachment) with a libraryDirectory for which a VirtualFile exists.

              This is about Persistence Unit scoping (JPA 6.2.2).

              • 4. Re: New persistence unit deployers
                starksm64

                Ok, provided the PersistenceUnitParsingDeployer runs after the JBossAppParsingDeployer, then whether the unit is an ear would be identified by an JBossAppMetaData attachment.

                • 5. Re: New persistence unit deployers
                  starksm64

                  I need to see the hibernate-entitymgr.jar source as the root problem is how is the org.hibernate.ejb.Ejb3Configuration generating the classname it is passing into the class loader:

                  Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: WEB-INF.classes.com.sun.ts.tests.ejb30.persistence.ee.common.Account
                   at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
                   at org.jboss.mx.loading.UnifiedClassLoader.loadClassImpl(UnifiedClassLoader.java:290)
                   at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:441)
                   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
                   at java.lang.Class.forName0(Native Method)
                   at java.lang.Class.forName(Class.java:242)
                   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112)
                   at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:967)
                   at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1039)
                   ... 59 more
                  



                  • 6. Re: New persistence unit deployers
                    wolfc

                    I found the class loading problem. I was passing the wrong persistence unit root url. Now I'm trying to get it to work with VFS.

                    Is the JBossAppMetaData attachment available for a jar inside the ear?

                    • 7. Re: New persistence unit deployers
                      starksm64

                       

                      "wolfc" wrote:

                      Is the JBossAppMetaData attachment available for a jar inside the ear?

                      Not the ear module deployment units, but they can walk up to the ear deployment unit using getParent().


                      • 8. Re: New persistence unit deployers
                        wolfc

                        Created a jarjar URL stream handler to provide Hibernate with an input stream in jar format.

                        It's still very hacky: http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas?view=rev&revision=67653

                        I'm now looking to get the PersistenceUnitDeployment on the same class loader as the TomcatDeployment.

                        • 9. Re: New persistence unit deployers
                          starksm64

                          Why is that needed? Can't you just pass in the VirtualFile.openStream/VFS URL InputStream to a JarInputStream?

                          • 10. Re: New persistence unit deployers
                            wolfc

                            http://java.sun.com/javaee/5/docs/api/javax/persistence/spi/PersistenceUnitInfo.html#getPersistenceUnitRootUrl()

                            I think we should challenge the spec itself. If it's allowed to have jar:myjar.jar!/somedirectory/ as a valid URL we're there (but Hibernate is not).

                            • 11. Re: New persistence unit deployers
                              wolfc