From user-return-18621-archive-asf-public=cust-asf.ponee.io@karaf.apache.org Fri May 25 14:51:55 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 76FDE180627 for ; Fri, 25 May 2018 14:51:53 +0200 (CEST) Received: (qmail 59757 invoked by uid 500); 25 May 2018 12:51:52 -0000 Mailing-List: contact user-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@karaf.apache.org Delivered-To: mailing list user@karaf.apache.org Received: (qmail 59747 invoked by uid 99); 25 May 2018 12:51:52 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 May 2018 12:51:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id CE33E1A3619 for ; Fri, 25 May 2018 12:51:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.312 X-Spam-Level: *** X-Spam-Status: No, score=3.312 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, KAM_SHORT=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=paremus-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id c82Zffywp3-F for ; Fri, 25 May 2018 12:51:46 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id DB0225FAC6 for ; Fri, 25 May 2018 12:51:45 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id u12-v6so9033433wrn.8 for ; Fri, 25 May 2018 05:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paremus-com.20150623.gappssmtp.com; s=20150623; h=from:mime-version:subject:date:references:to:in-reply-to:message-id; bh=oL4ILflhybOSuZjNpL2WjQ9y76WKLM1L8ArydHR+6s8=; b=s3oq7QXhDisMC2ju2jN1anNH8+pb16Vec2arKKeySjePbullU+vtvBDMmntFwYpaAd BL6i/xPcSWsb92bsxZPokSRuVasV2CJedtfmy2Lt7HSJbTEotjK0dFp0LtWvJFWhzhYh 3hSj92Nv28lCH/0dgu2uW7rRQDs3ILMWFBTJVqgt5XkHPIu8AAc0rORbGC5DSxqYpt91 RXwDNMRcCDZSlS1PSTE+H8a46QCYYoRHgpte7ru26Xg8KzACAT3IFqjkIq1Do+Ncu8qF B2LfCve40e6gIAWZ2loMlT6hIyiZ4c9s3xYKClTRHL3yOIw2s1rZLog7PgIs1Ujt0V9A 2yTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:mime-version:subject:date:references:to :in-reply-to:message-id; bh=oL4ILflhybOSuZjNpL2WjQ9y76WKLM1L8ArydHR+6s8=; b=ZK1AAm26Po+nryi30MRYHXaE9fkSUBpw+CZ8LTyvTfI9TKkonGcQDnmP19XG+9WUrF kSfaAaQTm8vsZt4GibMnEo2QQg6DmmAzzl+5T1h8QQ44OyIlIflM60zAlbHTewIiP3mJ 4Qycy8dHgCcW770UsyL5zAKopB8ImxL18xjZ78+WSWkSAY7DMTOhJ6/cAvwmXMKWeMwN ZsGT5dLferboDx88oQW6SoHisGxLLGeGzbJvtMj+YL09PkEc4qlPZroRq0stIdIPdlOJ cYzTdJXLoDmPwFtTJGguKkxuhC2fPZEULnvZGGUwr0kFwCmJHaF/Kq/aJXTrj3vzbn29 zl7w== X-Gm-Message-State: ALKqPwcWvCzg78P9RYr4aSUs6/T1Tj0xDf0Af4THW3oaCZOaaYp6yEIW S11TiRig4qobMKMfgDdK3lqWEF5mEZA= X-Google-Smtp-Source: ADUXVKKdEFLSJxL9Ya16v6yu9qA9ilEDFKr3jbkJ9zxs7bi7rnXi+YgMQ59PVb6ORnszJZHXrNZqkg== X-Received: by 2002:a19:de0a:: with SMTP id v10-v6mr1436976lfg.94.1527252705009; Fri, 25 May 2018 05:51:45 -0700 (PDT) Received: from [192.168.60.215] ([194.100.95.130]) by smtp.gmail.com with ESMTPSA id y128-v6sm4671169lfc.19.2018.05.25.05.51.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 05:51:44 -0700 (PDT) From: Tim Ward Content-Type: multipart/alternative; boundary="Apple-Mail=_ECB362CB-E18C-47B2-8EA2-707D52B827CE" Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: Aries JPA: The persistence unit has incomplete configuration and cannot be created. Date: Fri, 25 May 2018 15:51:42 +0300 References: <3C562862-A021-44B7-8771-337F70E12F4A@envieta.com> <1E95B8C3-6C51-4F71-AAA3-1F4F651B4E22@envieta.com> <7242946e-730f-e220-3f53-6152837aed57@nanthrax.net> To: user@karaf.apache.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3445.6.18) --Apple-Mail=_ECB362CB-E18C-47B2-8EA2-707D52B827CE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi Alex, It looks like you=E2=80=99ve managed to slide into a slightly awkward = gap between the expected ways of configuring your persistence unit. The main issue here is that it is expected that you either include all = DataSource information and configuration in the persistence.xml, or you = don=E2=80=99t put anything into the persistence.xml at all and do = everything in configuration admin. The problem is that the configuration = admin model does not support setting JNDI names for the DataSources, = only the use of DataSource factories. This is why you end up getting = errors about the configuration being =E2=80=9Cincomplete=E2=80=9D - the = container gets confused about the mixture of sources of datasource = configuration data. The best option I can come up with at the moment is to actually use the = builder yourself by doing something like: @Component public class EMFConfigurator { @Reference private EntityManagerFactoryBuilder emfb; @Reference private DataSource ds; @Reference private DataSource ds2; private EntityManagerFactory emf; @Activate void start(Map props) { Map jpaProps =3D new HashMap<>(props); =20 =20 jpaProps.put(=E2=80=9Cjavax.persistence.jtaDataSource=E2=80=9D, = ds); jpaProps.put(=E2=80=9Cjavax.persistence.nonJtaDataSource, ds2); // Or for resource local just use one non-jta datasource // jpaProps.put(=E2=80=9Cjavax.persistence.dataSource=E2=80=9D, = ds2); // This line also causes the emf to be registered as a service emf =3D emfb.createEntityManagerFactory(jpaProps); } @Deactivate void stop() { // This unregisters the emf service emf.close(); } } With a persistence xml containing: The configuration entries then target your component emfb.target=3D(osgi.unit.name=3DresponderPersistenUnit) ds.target=3D"(osgi.jndi.service.name=3Dresponder)=E2=80=9D= ds2.target=3D"(osgi.jndi.service.name=3Dresponder-non-jta)= " hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect hibernate.show_sql=3Dfalse hibernate.format_sql=3Dtrue hibernate.hbm2ddl.auto=3Dnone Best Regards, Tim > On 25 May 2018, at 15:01, Paul McCulloch = wrote: >=20 > The dialect can be left out of the pu.xml though. I started down this = path, but in the end have just relied on hibernate to select the correct = dialect. I deploy the same bundles on H2, Oracle & MSSQL with this = approach. >=20 >=20 > On 25 May 2018 at 12:51, Jean-Baptiste Onofr=C3=A9 > wrote: > Hi Paul, >=20 > yes, I remember this discussion, but AFAIR, it's always overriden by = the > dialect in the persistence.xml. >=20 > Regards > JB >=20 > On 25/05/2018 13:00, Paul McCulloch wrote: > > 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..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. > >=20 > > 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-td= 4043602.html = > >=20 > > On 25 May 2018 at 06:46, Jean-Baptiste Onofr=C3=A9 > > >> wrote: > >=20 > > Hi Alex, > >=20 > > the dialect HAS to be in the persistence.xml (it's in the JPA = spec). > >=20 > > AFAIK, Aries JPA doesn't provide a mechanism to provide the = dialect > > externally from the persistence.xml. > >=20 > > Even the Aries JPA itests define the dialect there: > >=20 > > = https://github.com/apache/aries-jpa/blob/master/itests/jpa-container-testb= undle/src/main/resources/META-INF/persistence.xml#L40 = > > = > > >=20 > > Further more, dialect also depends of the engine you are using > > (hibernate, openjpa, eclipselink). > >=20 > > Regards > > JB > >=20 > > On 24/05/2018 21:26, Alex Soto wrote: > > > If I change my persistence.xml to this: > > >=20 > > >=20 > > > > > > = osgi:service/javax.sql.DataSource/(osgi.jndi.service.name= > > >=3Dresponder) > > > = osgi:service/javax.sql.DataSource/(osgi.jndi.service.name= > > >=3Dresponder) =20 > > > =20 > > > > > >=20 > > > And the configuration entries to: > > >=20 > > > > > > =20 > > > = javax.persistence.provider=3Dorg.hibernate.jpa.HibernatePersistenceProvide= r > > > *javax.persistence.jdbc.driver=3Dorg.mariadb.jdbc.Driver* > > > hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect > > > hibernate.show_sql=3Dfalse > > > hibernate.format_sql=3Dtrue > > > hibernate.hbm2ddl.auto=3Dnone > > > > > > > > > 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.AriesEntityManagerFactoryBuilder.proce= ssProperties(AriesEntityManagerFactoryBuilder.java:225) > > > ~[?:?] > > > at > > > > > = org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.creat= eEntityManagerFactory(AriesEntityManagerFactoryBuilder.java:173) ~[?:?] > > > at > > > > > = org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:75)= > > > ~[?:?] > > > at > > > > > = org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServi= ceTracker.java:189) > > > ~[8:org.apache.felix.configadmin:1.8.16] > > > at > > > > > = org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(Manage= dServiceTracker.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(Con= figurationManager.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=3Dorg.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. > > >=20 > > > Also, my DataSource is already created by PAX JDBC Config and = this I > > > don=E2=80=99t want to change, since I am using PreHook = facility there to run > > > LiquiBase migrations. > > > Any hints or examples appreciated. > > >=20 > > >=20 > > > Best regards, > > > Alex soto > > >=20 > > >=20 > > >=20 > > >=20 > > >> On May 24, 2018, at 1:41 PM, Alex Soto > > > >> = >>> wrote: > > >> > > >> Hello, =20 > > >> > > >> I am using Aries JPA 2.7.0, I am trying provide the JPA = persistence > > >> configuration using configuration file. So my = persistence.xml. > > >> > > >> > >> xmlns=3D"http://java.sun.com/xml/ns/persistence = > > >" > > >> xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance = > > >" > > >> = xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence = > > > > > >> = http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd = > > >"> > > >> > > >> > >> transaction-type=3D"JTA"> > > >> =20 > > = org.hibernate.jpa.HibernatePersistenceProvider > > >> > > >> > > >> > > >> > > >> I deploy config file as part of my feature: > > >> > > >> > > >> = hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect > > >> hibernate.show_sql=3Dfalse > > >> hibernate.format_sql=3Dtrue > > >> hibernate.hbm2ddl.auto=3Dnone > > >> =20 > > >> =20 > > = jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service.nam= e > > >=3Dresponder) > > >> =20 > > >> =20 > > = non-jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service= .name > > >=3Dresponder) =20 > > >> =20 > > >> > > >> > > >> When I run, the following exception is thrown: > > >> > > >> > > >> java.lang.IllegalArgumentException: The persistence unit > > >> responderPersistenUnit has incomplete configuration and = cannot be > > >> created. The configuration > > >> =20 > > = is{non-jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.serv= ice.name > > >=3Dresponder), > > >> hibernate.format_sql=3Dtrue, hibernate.hbm2ddl.auto=3Dnone,= > > >> hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect, > > >> =20 > > = jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service.nam= e > > >=3Dresponder), = felix.fileinstall.filename=3Dfile:/Users/asoto/git/encryptedquery/responde= r/dist/target/encryptedquery-responder-dist-1.0.0-SNAPSHOT/etc/org.apache.= aries.jpa.responderPersistenUnit.cfg, > > >> =20 > > hibernate.show_sql=3Dfalse, = javax.persistence.spi.PersistenceUnitTransactionType=3DJTA, = service.pid=3Dorg.apache.aries.jpa.responderPersistenUnit} > > >> =20 > > at = org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.creat= eAndPublishEMF(AriesEntityManagerFactoryBuilder.java:365) > > >> ~[?:?] > > >> =20 > > at = org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.creat= eEntityManagerFactory(AriesEntityManagerFactoryBuilder.java:183) > > >> ~[?:?] > > >> at > > >> =20 > > = org.apache.aries.jpa.container.impl.ManagedEMF.updated(ManagedEMF.java:75)= > > >> ~[?:?] > > >> at > > >> =20 > > = org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServi= ceTracker.java:189) > > >> ~[8:org.apache.felix.configadmin:1.8.16] > > >> at > > >> =20 > > = org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(Manage= dServiceTracker.java:152) [8:org.apache.felix.configadmin:1.8.16] > > >> =20 > > at = org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration= (ManagedServiceTracker.java:85) [8:org.apache.felix.configadmin:1.8.16] > > >> =20 > > at = org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide= (ConfigurationManager.java:1479) [8:org.apache.felix.configadmin:1.8.16] > > >> =20 > > at = org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(Con= figurationManager.java:1435) [8:org.apache.felix.configadmin:1.8.16] > > >> at > > >> =20 > > = org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) = [8:org.apache.felix.configadmin:1.8.16] > > >> at > > >> =20 > > = 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 > > >> > > >> > > >> > > >> > > > > >=20 > > --=20 > > -- > > Jean-Baptiste Onofr=C3=A9 > > jbonofre@apache.org = > > > http://blog.nanthrax.net > > Talend - http://www.talend.com > >=20 > >=20 >=20 > --=20 > -- > Jean-Baptiste Onofr=C3=A9 > jbonofre@apache.org > http://blog.nanthrax.net > Talend - http://www.talend.com >=20 --Apple-Mail=_ECB362CB-E18C-47B2-8EA2-707D52B827CE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hi = Alex,

It looks like = you=E2=80=99ve managed to slide into a slightly awkward gap between the = expected ways of configuring your persistence unit.

The main issue here is = that it is expected that you either include all DataSource information = and configuration in the persistence.xml, or you don=E2=80=99t put = anything into the persistence.xml at all and do everything in = configuration admin. The problem is that the configuration admin model = does not support setting JNDI names for the DataSources, only the use of = DataSource factories. This is why you end up getting errors about the = configuration being =E2=80=9Cincomplete=E2=80=9D - the container gets = confused about the mixture of sources of datasource configuration = data.

The best = option I can come up with at the moment is to actually use the builder = yourself by doing something like:

@Component
public = class EMFConfigurator {

    @Reference
    = private EntityManagerFactoryBuilder emfb;

    @Reference
    private DataSource ds;

    = @Reference
    private DataSource = ds2;

    private EntityManagerFactory emf;

    = @Activate
    void start(Map<String, = Object> props) {
      =  Map<String, Object> jpaProps =3D new = HashMap<>(props);
      =  
      
      =  jpaProps.put(=E2=80=9Cjavax.persistence.jtaDataSource=E2=80=9D, = ds);
      =  jpaProps.put(=E2=80=9Cjavax.persistence.nonJtaDataSource, = ds2);

  =      // Or for resource local just use one non-jta = datasource
       // = jpaProps.put(=E2=80=9Cjavax.persistence.dataSource=E2=80=9D, = ds2);


       // This line = also causes the emf to be registered as a service
       emf =3D = emfb.createEntityManagerFactory(jpaProps);
  =   }

  =   @Deactivate
    void stop() = {
       // This unregisters = the emf service
      =  emf.close();
    }
}

With a persistence xml = containing:

= <persistence-unit name=3D"responderPersistenUnit" tran= saction-type=3D"JTA">
= </persistence-unit>

The configuration entries then target = your component

= <config name=3D=E2=80=9Cpid.for.your.component=E2=80=9D>=
  =               = emfb.target=3D(osgi.unit.name=3DresponderPersistenUnit)
      =           = ds.target=3D"(osgi.jndi.service.name=3Dresponder)=E2=80=9D
      =           = ds2.target=3D"(osgi.jndi.service.name=3Dresponder-non-jta)"
     = hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect
     = hibernate.show_sql=3Dfalse
     = hibernate.format_sql=3Dtrue
  =    = hibernate.hbm2ddl.auto=3Dnone
</config>


Best Regards,

Tim

On 25 May 2018, at 15:01, Paul = McCulloch <pkmcculloch@gmail.com> wrote:

The dialect can be left out of the pu.xml though. I started = down this path, but in the end have just relied on hibernate to select = the correct dialect. I deploy the same bundles on H2, Oracle & MSSQL = with this approach.


On 25 = May 2018 at 12:51, Jean-Baptiste Onofr=C3=A9 <jb@nanthrax.net> wrote:
Hi Paul,

yes, I remember this discussion, but AFAIR, it's always overriden by = the
dialect in the persistence.xml.

Regards
JB

On 25/05/2018 13:00, Paul McCulloch wrote:
> 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=C3=A9 <jb@nanthrax.net
> <mailto: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
>     <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=3D"responderPersistenUnit" transaction-type=3D"JTA">
>     > <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
>     <http://osgi.jndi.service.name>=3Dresponder)</jta-data-source>
>     > <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name >     <http://osgi.jndi.service.name>=3Dresponder)</jta-data-source>  
>     >  
>     > </persistence-unit>
>     >
>     > And the configuration entries to:
>     >
>     > <config name=3D"org.apache.aries.jpa.responderPersistenUnit">
>     >  
>     >   javax.persistence.provider=3Dorg.hibernate.jpa.HibernatePersistenceProvider
>     >   =   *javax.persistence.jdbc.driver=3Dorg.mariadb.jdbc.Driver*
>     >   =   hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect
>     >   =   hibernate.show_sql=3Dfalse
>     >   =   hibernate.format_sql=3Dtrue
>     >   =   hibernate.hbm2ddl.auto=3Dnone
>     > </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.AriesEntityManagerFactoryBuilder.processProperties(AriesEntityManagerFactoryBuilder.java:225)
>     > ~[?:?]
>     > at
>     >
>     org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.createEntityManagerFactory(AriesEntityManagerFactoryBuilder.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=3Dorg.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=E2=80=99t 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>
>     >> = <mailto: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=3D"2.0"
>     >>     xmlns=3D"http://java.sun.com/xml/ns/persistence
>     <http://java.sun.com/xml/ns/persistence>"
>     >>     xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance
>     <http://www.w3.org/2001/XMLSchema-instance>"
>     >>    =  xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence
>     <http://java.sun.com/xml/ns/persistence>
>     >>     http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd
>     <http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd>"> >     >>
>     >>     <persistence-unit = name=3D"responderPersistenUnit"
>     >>    =  transaction-type=3D"JTA">
>     >>   
>      <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
>     >>    =  </persistence-unit>
>     >>    =  </persistence>
>     >>
>     >>
>     >> I deploy config file as part of my = feature:
>     >>
>     >>    =  <config name=3D"org.apache.aries.jpa.responderPersistenUnit">
>     >>       =   hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect
>     >>       =   hibernate.show_sql=3Dfalse
>     >>       =   hibernate.format_sql=3Dtrue
>     >>       =   hibernate.hbm2ddl.auto=3Dnone
>     >>      
>     >>   
>        jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service.name
>     <http://osgi.jndi.service.name>=3Dresponder)
>     >>        
>     >>   
>      non-jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service.name >     <http://osgi.jndi.service.name>=3Dresponder)  
>     >>    =   
>     >>     </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=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service.name
>     <http://osgi.jndi.service.name>=3Dresponder),
>     >>    =  hibernate.format_sql=3Dtrue, hibernate.hbm2ddl.auto=3Dnone,
>     >>    =  hibernate.dialect=3Dorg.hibernate.dialect.MariaDBDialect,
>     >>   
>      jta-data-source=3Dosgi:service/javax.sql.DataSource/(osgi.jndi.service.name >     <http://osgi.jndi.service.name>=3Dresponder), felix.fileinstall.filename=3Dfile:/Users/asoto/git/encryptedquery/responder/dist/target/encryptedquery-responder-dist-1.0.0-SNAPSHOT/etc/org.apache.aries.jpa.responderPersistenUnit.cfg,
>     >>  =  
>      hibernate.show_sql=3Dfalse, javax.persistence.spi.PersistenceUnitTransactionType=3DJTA, service.pid=3Dorg.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=C3=A9
>     jbonofre@apache.org <mailto:jbonofre@apache.org>
>     http://blog.nanthrax.net
>     Talend - http://www.talend.com
>
>

--
--
Jean-Baptiste Onofr=C3=A9
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


= --Apple-Mail=_ECB362CB-E18C-47B2-8EA2-707D52B827CE--