Tapestry 5
  1. Tapestry 5
  2. TAP5-1848

tapestry-jpa ignores persistence provider from persistence.xml

    Details

      Description

      If I specify persistence provider class name in persistence.xml it might not be used by tapestry-jpa.

        Activity

        Hide
        Dmitry Gusev added a comment -

        This blocks deployment Tap5 apps to GAE.

        Show
        Dmitry Gusev added a comment - This blocks deployment Tap5 apps to GAE.
        Hide
        Dmitry Gusev added a comment -

        Here's a workaround until the patch applied (add to AppModule):

        public static EntityManagerSource decorateEntityManagerSource(final Logger logger,
        @Symbol(JpaSymbols.PERSISTENCE_DESCRIPTOR) final Resource persistenceDescriptor,
        PersistenceUnitConfigurer packageNamePersistenceUnitConfigurer)
        {
        // XXX Waiting for https://issues.apache.org/jira/browse/TAP5-1848
        return new EntityManagerSourceImpl(logger, persistenceDescriptor, packageNamePersistenceUnitConfigurer,
        new HashMap<String, PersistenceUnitConfigurer>())
        {
        private Map<String, EntityManagerFactory> entityManagerFactories = getEntityManagerFactories();

        @SuppressWarnings("unchecked")
        private Map<String, EntityManagerFactory> getEntityManagerFactories()
        {
        Field field = null;
        try

        { field = this.getClass().getSuperclass().getDeclaredField("entityManagerFactories"); field.setAccessible(true); return (Map<String, EntityManagerFactory>) field.get(this); }

        catch (Exception e)

        { throw new RuntimeException("Error accessing private field", e); }

        finally

        { if (field != null) field.setAccessible(false); }

        }

        @Override
        public EntityManagerFactory getEntityManagerFactory(String persistenceUnitName)
        {
        EntityManagerFactory emf = entityManagerFactories.get(persistenceUnitName);

        if (emf == null)

        { emf = Persistence.createEntityManagerFactory(persistenceUnitName); entityManagerFactories.put(persistenceUnitName, emf); }

        return emf;
        }
        };
        }

        Show
        Dmitry Gusev added a comment - Here's a workaround until the patch applied (add to AppModule): public static EntityManagerSource decorateEntityManagerSource(final Logger logger, @Symbol(JpaSymbols.PERSISTENCE_DESCRIPTOR) final Resource persistenceDescriptor, PersistenceUnitConfigurer packageNamePersistenceUnitConfigurer) { // XXX Waiting for https://issues.apache.org/jira/browse/TAP5-1848 return new EntityManagerSourceImpl(logger, persistenceDescriptor, packageNamePersistenceUnitConfigurer, new HashMap<String, PersistenceUnitConfigurer>()) { private Map<String, EntityManagerFactory> entityManagerFactories = getEntityManagerFactories(); @SuppressWarnings("unchecked") private Map<String, EntityManagerFactory> getEntityManagerFactories() { Field field = null; try { field = this.getClass().getSuperclass().getDeclaredField("entityManagerFactories"); field.setAccessible(true); return (Map<String, EntityManagerFactory>) field.get(this); } catch (Exception e) { throw new RuntimeException("Error accessing private field", e); } finally { if (field != null) field.setAccessible(false); } } @Override public EntityManagerFactory getEntityManagerFactory(String persistenceUnitName) { EntityManagerFactory emf = entityManagerFactories.get(persistenceUnitName); if (emf == null) { emf = Persistence.createEntityManagerFactory(persistenceUnitName); entityManagerFactories.put(persistenceUnitName, emf); } return emf; } }; }
        Hide
        Dmitry Gusev added a comment -

        Fix with a test case

        Show
        Dmitry Gusev added a comment - Fix with a test case
        Hide
        Dmitry Gusev added a comment -

        The fix

        Show
        Dmitry Gusev added a comment - The fix
        Hide
        Dmitry Gusev added a comment -

        Forget to mention, the patch is against the trunk.
        But I guess it should be easy to back port it to 5.3.2.

        Show
        Dmitry Gusev added a comment - Forget to mention, the patch is against the trunk. But I guess it should be easy to back port it to 5.3.2.
        Hide
        Hudson added a comment -

        Integrated in tapestry-trunk-freestyle #705 (See https://builds.apache.org/job/tapestry-trunk-freestyle/705/)
        TAP5-1848: Persistence providers defined for a unit is not ignored anymore (Revision 1329111)

        Result = SUCCESS
        drobiazko : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1329111
        Files :

        • /tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5/Index.tml
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5/WEB-INF
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5/WEB-INF/web.xml
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/conf/testng.xml
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManager.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManagerFactory.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyPersistenceProvider.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/ExplicitPersistenceProviderClassTest.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/pages
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/pages/Index.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/services
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/services/AppModule.java
        • /tapestry/tapestry5/trunk/tapestry-jpa/src/test/resources/explicit-persistence-provider-class-persistence-unit.xml
        Show
        Hudson added a comment - Integrated in tapestry-trunk-freestyle #705 (See https://builds.apache.org/job/tapestry-trunk-freestyle/705/ ) TAP5-1848 : Persistence providers defined for a unit is not ignored anymore (Revision 1329111) Result = SUCCESS drobiazko : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1329111 Files : /tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5 /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5/Index.tml /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5/WEB-INF /tapestry/tapestry5/trunk/tapestry-jpa/src/test/app5/WEB-INF/web.xml /tapestry/tapestry5/trunk/tapestry-jpa/src/test/conf/testng.xml /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5 /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManager.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManagerFactory.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyPersistenceProvider.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/ExplicitPersistenceProviderClassTest.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5 /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/pages /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/pages/Index.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/services /tapestry/tapestry5/trunk/tapestry-jpa/src/test/java/org/example/app5/services/AppModule.java /tapestry/tapestry5/trunk/tapestry-jpa/src/test/resources/explicit-persistence-provider-class-persistence-unit.xml
        Hide
        Hudson added a comment -

        Integrated in tapestry-5.3-freestyle #25 (See https://builds.apache.org/job/tapestry-5.3-freestyle/25/)
        TAP5-1848: Backporting into 5.3 branch (Revision 1329126)

        Result = FAILURE
        drobiazko : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1329126
        Files :

        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5/Index.tml
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5/WEB-INF
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5/WEB-INF/web.xml
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/conf/testng.xml
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManager.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManagerFactory.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyPersistenceProvider.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/ExplicitPersistenceProviderClassTest.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/pages
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/pages/Index.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/services
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/services/AppModule.java
        • /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/resources/explicit-persistence-provider-class-persistence-unit.xml
        Show
        Hudson added a comment - Integrated in tapestry-5.3-freestyle #25 (See https://builds.apache.org/job/tapestry-5.3-freestyle/25/ ) TAP5-1848 : Backporting into 5.3 branch (Revision 1329126) Result = FAILURE drobiazko : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1329126 Files : /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerSourceImpl.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5 /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5/Index.tml /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5/WEB-INF /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/app5/WEB-INF/web.xml /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/conf/testng.xml /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5 /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManager.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyEntityManagerFactory.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/DummyPersistenceProvider.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/apache/tapestry5/jpa/integration/app5/ExplicitPersistenceProviderClassTest.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5 /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/pages /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/pages/Index.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/services /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/java/org/example/app5/services/AppModule.java /tapestry/tapestry5/branches/5.3/tapestry-jpa/src/test/resources/explicit-persistence-provider-class-persistence-unit.xml

          People

          • Assignee:
            Igor Drobiazko
            Reporter:
            Dmitry Gusev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development