karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul McCulloch <pkmccull...@gmail.com>
Subject Re: Aries JPA: The persistence unit has incomplete configuration and cannot be created.
Date Fri, 25 May 2018 11:00:26 GMT
Hibernate usually does a reasonable job of auto detecting the dialect, in
my experience. If you need to override this then Aries JPA supports
creating a configuration file /etc/org.apache.aries.jpa.<PU name>.cfg where
you can override hibernate.dialect. Beware if you have a "-" in the PU name
as I think fileinstall we try and create a factory config.

I can't recall where I got this info from. It might have been here:
http://karaf.922171.n3.nabble.com/Dynamic-parameters-in-persistence-xml-td4043602.html

On 25 May 2018 at 06:46, Jean-Baptiste Onofré <jb@nanthrax.net> wrote:

> Hi Alex,
>
> the dialect HAS to be in the persistence.xml (it's in the JPA spec).
>
> AFAIK, Aries JPA doesn't provide a mechanism to provide the dialect
> externally from the persistence.xml.
>
> Even the Aries JPA itests define the dialect there:
>
> https://github.com/apache/aries-jpa/blob/master/itests/
> jpa-container-testbundle/src/main/resources/META-INF/persistence.xml#L40
>
> Further more, dialect also depends of the engine you are using
> (hibernate, openjpa, eclipselink).
>
> Regards
> JB
>
> On 24/05/2018 21:26, Alex Soto wrote:
> > If I change my persistence.xml to this:
> >
> >
> > <persistence-unit name="responderPersistenUnit" transaction-type="JTA">
> > <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.
> jndi.service.name=responder)</jta-data-source>
> > <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.
> jndi.service.name=responder)</jta-data-source>
> >
> > </persistence-unit>
> >
> > And the configuration entries to:
> >
> > <config name="org.apache.aries.jpa.responderPersistenUnit">
> >
> >   javax.persistence.provider=org.hibernate.jpa.
> HibernatePersistenceProvider
> >     *javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver*
> >     hibernate.dialect=org.hibernate.dialect.MariaDBDialect
> >     hibernate.show_sql=false
> >     hibernate.format_sql=true
> >     hibernate.hbm2ddl.auto=none
> > </config>
> >
> > Then the error Is:
> >
> >
> > java.lang.IllegalArgumentException: Cannot rebind to a different
> > database driver, as per the JPA service specification
> > at
> > org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuild
> er.processProperties(AriesEntityManagerFactoryBuilder.java:225)
> > ~[?:?]
> > at
> > org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuild
> er.createEntityManagerFactory(AriesEntityManagerFactoryBuild
> er.java:173) ~[?:?]
> > at
> > org.apache.aries.jpa.container.impl.ManagedEMF.
> updated(ManagedEMF.java:75)
> > ~[?:?]
> > at
> > org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> updated(ManagedServiceTracker.java:189)
> > ~[8:org.apache.felix.configadmin:1.8.16]
> > at
> > org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(
> ManagedServiceTracker.java:152) [8:org.apache.felix.configadmin:1.8.16]
> > at
> > org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> provideConfiguration(ManagedServiceTracker.java:85) [8:org.apache.felix.
> configadmin:1.8.16]
> > at
> > org.apache.felix.cm.impl.ConfigurationManager$
> ManagedServiceUpdate.provide(ConfigurationManager.java:
> 1479) [8:org.apache.felix.configadmin:1.8.16]
> > at
> > org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(
> ConfigurationManager.java:1435) [8:org.apache.felix.configadmin:1.8.16]
> > at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141)
> > [8:org.apache.felix.configadmin:1.8.16]
> > at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109)
> > [8:org.apache.felix.configadmin:1.8.16]
> > at java.lang.Thread.run(Thread.java:748) [?:?]
> >
> >
> > If I remove the
> > line *javax.persistence.jdbc.driver=org.mariadb.jdbc.Driver *from the
> > config file above, then I get the previous error about configuration not
> > being completed.  What I am trying to do is to not  hard code
> >  the /hibernate.dialect /inside the bundle, so I can switch to a
> > different database without having to rebuild.
> >
> > Also, my DataSource is already created by PAX JDBC Config and this I
> > don’t want to change, since I am using PreHook facility there to run
> > LiquiBase migrations.
> > Any hints or examples appreciated.
> >
> >
> > Best regards,
> > Alex soto
> >
> >
> >
> >
> >> On May 24, 2018, at 1:41 PM, Alex Soto <alex.soto@envieta.com
> >> <mailto:alex.soto@envieta.com>> wrote:
> >>
> >> Hello,
> >>
> >> I am using Aries JPA 2.7.0, I am trying provide the JPA persistence
> >> configuration using configuration file.  So my persistence.xml.
> >>
> >>     <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="responderPersistenUnit"
> >>     transaction-type="JTA">
> >>     <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
> >>     </persistence-unit>
> >>     </persistence>
> >>
> >>
> >> I deploy config file as part of my feature:
> >>
> >>     <config name="org.apache.aries.jpa.responderPersistenUnit">
> >>         hibernate.dialect=org.hibernate.dialect.MariaDBDialect
> >>         hibernate.show_sql=false
> >>         hibernate.format_sql=true
> >>         hibernate.hbm2ddl.auto=none
> >>
> >>       jta-data-source=osgi:service/javax.sql.DataSource/(
> osgi.jndi.service.name=responder)
> >>
> >>     non-jta-data-source=osgi:service/javax.sql.DataSource/(
> osgi.jndi.service.name=responder)
> >>
> >>     </config>
> >>
> >> When I run, the following exception is thrown:
> >>
> >>
> >>     java.lang.IllegalArgumentException: The persistence unit
> >>     responderPersistenUnit has incomplete configuration and cannot be
> >>     created. The configuration
> >>     is{non-jta-data-source=osgi:service/javax.sql.DataSource/(
> osgi.jndi.service.name=responder),
> >>     hibernate.format_sql=true, hibernate.hbm2ddl.auto=none,
> >>     hibernate.dialect=org.hibernate.dialect.MariaDBDialect,
> >>     jta-data-source=osgi:service/javax.sql.DataSource/(osgi.
> jndi.service.name=responder), felix.fileinstall.filename=
> file:/Users/asoto/git/encryptedquery/responder/dist/target/encryptedquery-
> responder-dist-1.0.0-SNAPSHOT/etc/org.apache.aries.jpa.
> responderPersistenUnit.cfg,
> >>     hibernate.show_sql=false, javax.persistence.spi.
> PersistenceUnitTransactionType=JTA, service.pid=org.apache.aries.jpa.
> responderPersistenUnit}
> >>     at org.apache.aries.jpa.container.impl.
> AriesEntityManagerFactoryBuilder.createAndPublishEMF(
> AriesEntityManagerFactoryBuilder.java:365)
> >>     ~[?:?]
> >>     at org.apache.aries.jpa.container.impl.
> AriesEntityManagerFactoryBuilder.createEntityManagerFactory(
> AriesEntityManagerFactoryBuilder.java:183)
> >>     ~[?:?]
> >>     at
> >>     org.apache.aries.jpa.container.impl.ManagedEMF.
> updated(ManagedEMF.java:75)
> >>     ~[?:?]
> >>     at
> >>     org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> updated(ManagedServiceTracker.java:189)
> >>     ~[8:org.apache.felix.configadmin:1.8.16]
> >>     at
> >>     org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> updateService(ManagedServiceTracker.java:152) [8:org.apache.felix.
> configadmin:1.8.16]
> >>     at org.apache.felix.cm.impl.helper.ManagedServiceTracker.
> provideConfiguration(ManagedServiceTracker.java:85) [8:org.apache.felix.
> configadmin:1.8.16]
> >>     at org.apache.felix.cm.impl.ConfigurationManager$
> ManagedServiceUpdate.provide(ConfigurationManager.java:
> 1479) [8:org.apache.felix.configadmin:1.8.16]
> >>     at org.apache.felix.cm.impl.ConfigurationManager$
> ManagedServiceUpdate.run(ConfigurationManager.java:
> 1435) [8:org.apache.felix.configadmin:1.8.16]
> >>     at
> >>     org.apache.felix.cm.impl.UpdateThread.run0(
> UpdateThread.java:141) [8:org.apache.felix.configadmin:1.8.16]
> >>     at
> >>     org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.
> java:109) [8:org.apache.felix.configadmin:1.8.16]
> >>     at java.lang.Thread.run(Thread.java:748) [?:?]
> >>
> >>
> >>
> >> So Aries JPA is finding the configuration properties I am providing,
> >> but still missing something.  What else is needed as configuration
> >> properties? Why is it not complete the persistent unit?
> >>
> >>
> >> Best regards,
> >> Alex soto
> >>
> >>
> >>
> >>
> >
>
> --
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Mime
View raw message