1 Reply Latest reply on Apr 4, 2016 11:01 AM by white_crow

    Problem with custom PersistenceProvider packed within the application - what am I missing?

    white_crow

      Hi everyone

       

      I'm struggling with setting up my application in order to package a custom PersistenceProvider:

       

      According to the documentation, the only thing required is to have the property providerMoule set to 'application'. And within the provider-tag, I set the fully qualified name of my custom PersistenceProvider.

      So my persistence.xml basically looks like:

       

      <persistence>

          <persistence-unit>

                <class>org.url.my.TestEntity</class>

                <provider>org.url.my.CustomPersistenceProvider</provider>

                <jta-data-source>java:/jdbc/myappy</jta-data-source>

                  <properties>

                      <property name="jboss.as.jpa.providerModule" value="application"></property>

                  </properties>

          </persistence-unit>

      </persistence>

       

      At first everything seems to be fine, tables are correctly created and server is starting. However, it is not possible to insert any data with the EntityManager injected with @PersistenceContext. Trying to insert data does NOT throw an exception, it simply does not happen.

      Strangely I have the exact same behavior, if I set the provider to org.eclipse.persistence.jpa.PersistenceProvider and package the EclipseLink jars withing the application. Also, creating a custom module on Wildfly, containing my custom PersistenceProvider does not work.

       

      It only works, if I install the EclipseLink jars as a module on Wildfly and working with the default PersistenceProvider...

       

      Does anybody know what I'm missing or has some experience with custom PersistenceProviders?

       

      Cheers

        • 1. Re: Problem with custom PersistenceProvider packed within the application - what am I missing?
          white_crow

          Hi

           

          I found the solution! In order to activate JTA for a custom PersistenceProvider, it is important to provide the eclipselink.target-server property and set it to JBoss:

           

          <persistence>

              <persistence-unit>

                    <class>org.url.my.TestEntity</class>

                    <provider>org.url.my.CustomPersistenceProvider</provider>

                    <jta-data-source>java:/jdbc/myappy</jta-data-source>

                      <properties>

                          <property name="jboss.as.jpa.providerModule" value="application"></property>

                          <property name="eclipselink.target-server" value="JBoss"></property>

                      </properties>

              </persistence-unit>

          </persistence>

           

          Cheers