Two Karaf instances using one database

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Two Karaf instances using one database

Dominik Marciniszyn
Hi,

I have got two karaf instances with my programs. Both of them uses the same
database. I run them in DOSGI with Karaf-Cellar-DOSGI. First instance runs
well, but second has got problem with jndi. The first instance see my DB,
but second don't. I was trying to configure HA/Lock configuration but still
the same problem. Could someone give me a hint how could I use one db by
multiple karaf instances in DOSGI with Cellar?



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

jbonofre
Hi

Can I get the log of the second instance please ?

Thanks
Regards
JB
On Dec 7, 2017, at 17:56, Dominik Marciniszyn <[hidden email]> wrote:
Hi,

I have got two karaf instances with my programs. Both of them uses the same
database. I run them in DOSGI with Karaf-Cellar-DOSGI. First instance runs
well, but second has got problem with jndi. The first instance see my DB,
but second don't. I was trying to configure HA/Lock configuration but still
the same problem. Could someone give me a hint how could I use one db by
multiple karaf instances in DOSGI with Cellar?



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
The error from logs from second instance:

11:18:36,520 | ERROR | FelixStartLevel  | Felix | Bundle
org.apache.aries.jpa.container [88] EventDispatcher: Error during dispatch.
(java.lang.IllegalArgumentException: No DataSource supplied in
persistence.xml)
java.lang.IllegalArgumentException: No DataSource supplied in
persistence.xml
        at
org.apache.aries.jpa.container.impl.DataSourceTracker.createFilter(DataSourceTracker.java:54)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.DataSourceTracker.<init>(DataSourceTracker.java:46)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.PersistenceProviderTracker.createDataSourceTracker(PersistenceProviderTracker.java:121)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:88)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:44)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
[?:?]
        at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
[?:?]
        at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
[?:?]
        at
org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
[?:?]
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318) [?:?]
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261) [?:?]
        at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.trackProvider(PersistenceBundleTracker.java:103)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.findPersistenceUnits(PersistenceBundleTracker.java:87)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:66)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:39)
[88:org.apache.aries.jpa.container:2.6.0]
        at
org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
[?:?]
        at
org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)
[?:?]
        at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
[?:?]
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
[?:?]
        at
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
[?:?]
        at
org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
[?:?]
        at
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
[?:?]
        at
org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
[?:?]
        at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4562) [?:?]
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2229) [?:?]
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2144) [?:?]
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
[?:?]
        at
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
[?:?]
        at java.lang.Thread.run(Thread.java:745) [?:?]



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

fpapon

Hi,

What datasource is declared in the persistence.xml of your bundle who use JPA ?

Have you deployed your bundle manually on each instance or using Cellar ?


Le 07/12/2017 à 14:25, Dominik Marciniszyn a écrit :
The error from logs from second instance:

11:18:36,520 | ERROR | FelixStartLevel  | Felix | Bundle
org.apache.aries.jpa.container [88] EventDispatcher: Error during dispatch.
(java.lang.IllegalArgumentException: No DataSource supplied in
persistence.xml)
java.lang.IllegalArgumentException: No DataSource supplied in
persistence.xml
	at
org.apache.aries.jpa.container.impl.DataSourceTracker.createFilter(DataSourceTracker.java:54)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.DataSourceTracker.<init>(DataSourceTracker.java:46)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.PersistenceProviderTracker.createDataSourceTracker(PersistenceProviderTracker.java:121)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:88)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.PersistenceProviderTracker.addingService(PersistenceProviderTracker.java:44)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
[?:?]
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
[?:?]
	at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
[?:?]
	at
org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
[?:?]
	at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318) [?:?]
	at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261) [?:?]
	at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.trackProvider(PersistenceBundleTracker.java:103)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.findPersistenceUnits(PersistenceBundleTracker.java:87)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:66)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.apache.aries.jpa.container.impl.PersistenceBundleTracker.addingBundle(PersistenceBundleTracker.java:39)
[88:org.apache.aries.jpa.container:2.6.0]
	at
org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
[?:?]
	at
org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)
[?:?]
	at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
[?:?]
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
[?:?]
	at
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
[?:?]
	at
org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
[?:?]
	at
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
[?:?]
	at
org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
[?:?]
	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4562) [?:?]
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2229) [?:?]
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2144) [?:?]
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
[?:?]
	at
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
[?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Francois Papon
Openrun : https://www.openrun.re
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
In persistence.xml I have got:
<persistence-unit name="my_persistence_unit" transaction-type="JTA">
                <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
       
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=my_persistence_unit)</jta-data-source>
               
               
                <mapping-file>META-INF/orm.xml</mapping-file>
                ...
       
                <exclude-unlisted-classes>true</exclude-unlisted-classes>
               
                <properties>
                        <property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
                        <property name="hibernate.archive.autodetection" value="class"/>
                        <property name="hibernate.enable_lazy_load_no_trans" value="true"/>
            <property name="hibernate.connection.isolation" value="4"/>
            <property name="hibernate.connection.autocommit" value="false"/>
                </properties>
        </persistence-unit>
</persistence>

I have got the two Karafs with my programs and then I've added the Cellar
and Cellar-DOSGI features. Next I've put both instances into one group (not
default).



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

fpapon
How do you declare the datasource ? (config properties file)

Do you see the datasource list with karaf commands ?

karaf@root()> jdbc:ds-list

Name      │ Product │ Version │ URL │ Status





Le 07/12/2017 à 15:30, Dominik Marciniszyn a écrit :

> In persistence.xml I have got:
> <persistence-unit name="my_persistence_unit" transaction-type="JTA">
> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
>
> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=my_persistence_unit)</jta-data-source>
>
>
> <mapping-file>META-INF/orm.xml</mapping-file>
> ...
>        
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>
> <properties>
> <property name="hibernate.dialect"
> value="org.hibernate.dialect.Oracle10gDialect" />
> <property name="hibernate.archive.autodetection" value="class"/>
> <property name="hibernate.enable_lazy_load_no_trans" value="true"/>
>             <property name="hibernate.connection.isolation" value="4"/>
>             <property name="hibernate.connection.autocommit" value="false"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> I have got the two Karafs with my programs and then I've added the Cellar
> and Cellar-DOSGI features. Next I've put both instances into one group (not
> default).
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Francois Papon
Openrun : https://www.openrun.re
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
Only on first Karaf instance everything works well. On the second I see
nothing. I was trying to declare other datasource but it won't help. I mean
other datasource name.

My config for ds looks:

osgi.jdbc.driver.name=oracle-pool-xa
url=jdbc:oracle:thin:@localhost:1521:XE
user=user
password=password
databaseName=MyDB
dataSourceName=my_persistence_unit

The filename of this config is:
"org.ops4j.datasource-my_persistence_unit.cfg"



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

fpapon
Your instance are deployed on the same machine (just to confirm because
your database url is localhost) ?

Do you have the same feature installed and started, same jdbc oracle
drivers ?

It seems like bundle or feature are missing in your second instance.


Le 07/12/2017 à 15:44, Dominik Marciniszyn a écrit :

> Only on first Karaf instance everything works well. On the second I see
> nothing. I was trying to declare other datasource but it won't help. I mean
> other datasource name.
>
> My config for ds looks:
>
> osgi.jdbc.driver.name=oracle-pool-xa
> url=jdbc:oracle:thin:@localhost:1521:XE
> user=user
> password=password
> databaseName=MyDB
> dataSourceName=my_persistence_unit
>
> The filename of this config is:
> "org.ops4j.datasource-my_persistence_unit.cfg"
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Francois Papon
Openrun : https://www.openrun.re
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
Yes I have on one machine both instances. I think I have got the same
required features, I will check once again. The jdbc oracle drivers for sure
are the same.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

jbonofre
In reply to this post by Dominik Marciniszyn
I guess you deploy the cfg file by hand (creating the cfg by hand).

In that case, to sync the cfg file on the second instance, you have to enable the local config listener in the cellar node cfg file (it's disable by default).

Regards
JB
On Dec 7, 2017, at 19:44, Dominik Marciniszyn <[hidden email]> wrote:
Only on first Karaf instance everything works well. On the second I see
nothing. I was trying to declare other datasource but it won't help. I mean
other datasource name.

My config for ds looks:

osgi.jdbc.driver.name=oracle-pool-xa
url=jdbc:oracle:thin:@localhost:1521:XE
user=user
password=password
databaseName=MyDB
dataSourceName=my_persistence_unit

The filename of this config is:
"org.ops4j.datasource-my_persistence_unit.cfg"



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
I've checked the features on both Karaf instances and all is the same.
About creating cfg, I tried to sync cfg file as you say JBonofre but still
nothing. I assume that after sync the cfg file should appear on second Karaf
but nothing happens. Still I don't have nothing in 'ds-name' and jndi:names
(by nothing I mean only basic 'osgi:service/jndi |
org.apache.karaf.jndi.internal.JndiServiceImpl). It should be
oracle.jdbc.pool.OracleDataSource.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

jbonofre
I'm pretty sure the cfg is not on the second instance (you can check with config:list). That's why the data source is not there.

As I said to sync the cfg you have to use cluster:config* commands or you have to enable config.listener=true in etc/org.apache.karaf.cellar.node.cfg file BEFORE creating or modifying the data source cfg file.

Regards
JB
On Dec 7, 2017, at 20:40, Dominik Marciniszyn <[hidden email]> wrote:
I've checked the features on both Karaf instances and all is the same.
About creating cfg, I tried to sync cfg file as you say JBonofre but still
nothing. I assume that after sync the cfg file should appear on second Karaf
but nothing happens. Still I don't have nothing in 'ds-name' and jndi:names
(by nothing I mean only basic 'osgi:service/jndi |
org.apache.karaf.jndi.internal.JndiServiceImpl). It should be
oracle.jdbc.pool.OracleDataSource.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
Thank you for advice jbonofre. I tried but the datasource is on the cluster.
I've checked with command cluster:config-list. I also did the tests on cross
and star topology. Sync and manually adding config to cluster configs will
not solve the problem. I don't have any idea what else could be wrong. I am
using Karaf 4.1.1 and Karaf Cellar 4.0.0.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

jbonofre
Hi Dominik,

sorry for the late feedback, I was on different flights.

Can you share your log file (in direct message) ?
In the mean time, I will try to reproduce.

Regards
JB

On 12/08/2017 08:05 AM, Dominik Marciniszyn wrote:

> Thank you for advice jbonofre. I tried but the datasource is on the cluster.
> I've checked with command cluster:config-list. I also did the tests on cross
> and star topology. Sync and manually adding config to cluster configs will
> not solve the problem. I don't have any idea what else could be wrong. I am
> using Karaf 4.1.1 and Karaf Cellar 4.0.0.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
There is no problem jbonofre, Thank You for helping.
Yes, I only need to clear the logs and I will send you in logs in direct
message.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
I saw also one thing. Let's name two instances of karaf A and B. When I start
A as first and B as second only A works well. When I change the order and
start B first then A, only B works. The instance which works is only first
which I run.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

jbonofre
Yes, that's probably because a feature/config/bundle is not sync.

If you can send the test case to me (private e-mail) and log, that would be great.

Thanks !
Regards
JB

On 12/13/2017 10:27 AM, Dominik Marciniszyn wrote:

> I saw also one thing. Let's name two instances of karaf A and B. When I start
> A as first and B as second only A works well. When I change the order and
> start B first then A, only B works. The instance which works is only first
> which I run.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
I did one more test. I've created simple environment based on two karaf
instances with cellar and cellar-dosgi. I've take karaf 4.1.1 and cellar
4.1.1.

First I set up ports on karaf instances for allow to run both. Then I use
command:
install -s wrap:mvn:com.oracle/ojdbc6/11.2.0

Next I've installed:
feature:install jpa jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle
transaction

Then I've defined DS by using jdbc:ds-create command:
jdbc:ds-create -dbName DBName -dt DataSource -dn oracle -dc
oracle.jdbc.OracleDriver -u user -p passwd -url
jdbc:oracle:thin:@localhost:1521:XE Name

I did it on both karaf instances without Cellar and both instances had
defined DS. Then I've installed Cellar and Cellar DOSGI on both. After
installation DS was still avaliable on both. After restart only first
instance had DS defined, second not.

I attached file with logs from second Karaf instance.
Logs.txt <http://karaf.922171.n3.nabble.com/file/t497885/Logs.txt>  




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

jbonofre
I will check, but it depends of the sync policy define on the node as you didn't
use cluster:feature-install.

Give me time to complete 4.1.4 release preparation and I will test.

Regards
JB

On 12/15/2017 12:47 PM, Dominik Marciniszyn wrote:

> I did one more test. I've created simple environment based on two karaf
> instances with cellar and cellar-dosgi. I've take karaf 4.1.1 and cellar
> 4.1.1.
>
> First I set up ports on karaf instances for allow to run both. Then I use
> command:
> install -s wrap:mvn:com.oracle/ojdbc6/11.2.0
>
> Next I've installed:
> feature:install jpa jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle
> transaction
>
> Then I've defined DS by using jdbc:ds-create command:
> jdbc:ds-create -dbName DBName -dt DataSource -dn oracle -dc
> oracle.jdbc.OracleDriver -u user -p passwd -url
> jdbc:oracle:thin:@localhost:1521:XE Name
>
> I did it on both karaf instances without Cellar and both instances had
> defined DS. Then I've installed Cellar and Cellar DOSGI on both. After
> installation DS was still avaliable on both. After restart only first
> instance had DS defined, second not.
>
> I attached file with logs from second Karaf instance.
> Logs.txt <http://karaf.922171.n3.nabble.com/file/t497885/Logs.txt>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Two Karaf instances using one database

Dominik Marciniszyn
I did a little progress. I've install everything on first Karaf as in
previous message and I used karaf command: 'instance:clone' with parameters.
Then I saw that datasource exists on cloned instance. And the datasource is
also on the first instance.

Now I see that cluster:sync not working as I thought. I've installed my
example bundle on first instance. And I did sync, but the sync not add on
the second instance the bundle but removes it from first. I have got cross
topology and cluster scope on all. Both instances are in the same group. But
still I don't know why prevoius method won't work.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
12