You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Bram Pouwelse <br...@pouwelse.com> on 2013/06/10 19:03:32 UTC

Aries JPA bundle start order issues

Hi,

I've sent the message below to the Aries list last week, but no response
yet. I'm wondering if other Karaf users are having the same issue using the
JPA feature in Karaf.



I'm having some problems using Aries JPA (running on Karaf 2.3.1 and using
OpenJPA 2.2.1) .

The first problem is that the EntityManagerFactory is created and
registered in the service registry even if the DataSource is not available,
this causes a problem because other bundles start using the
EntityManagerFactory based on it's availability.

Is it possible to register the EntityManagerFactory only of the DataSource
is available (I'm using JNDI). For now I've added a service dependency on
the DataSource to bundles to make them aware of the fact that
the EntityManagerFactory can't be used.


The second problem I have is that when I restart the bundle that registers
the DataSource I get an IllegalStateException [1] when using JPA. The only
way to get JPA working again is restarting the JPA Container bundle.


The solution for the first issue seems to work pretty well, but it would be
really nice to be able to update the DataSource bundle without having to
restart the JPA Container.

Any idea's on how to overcome the IllegalStateException?

Thanks!

Bram

[1]: Caused by: java.lang.IllegalStateException: Invalid BundleContext.
at
org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:514)
at
org.apache.felix.framework.BundleContextImpl.getServiceReferences(BundleContextImpl.java:425)
at org.apache.aries
.jndi.services.ServiceHelper.findService(ServiceHelper.java:375)
at org.apache.aries
.jndi.services.ServiceHelper.access$500(ServiceHelper.java:66)
at org.apache.aries
.jndi.services.ServiceHelper$JNDIServiceDamper.call(ServiceHelper.java:180)
at Proxyca2dc362_3bc7_421c_ba6d_a2b9855d61d6.getConnection(Unknown Source)
at org.apache.aries
.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
at
org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:110)

Re: Aries JPA bundle start order issues

Posted by lbu <lb...@gmail.com>.
Hi,
this seems a common issue while working with Aries JPA:

from Stack Overflow
(http://stackoverflow.com/questions/9430270/enterprise-osgi-frameworks-maturity-comparison-apache-aries-vs-eclipse-gemini):

3: As I like using JTA it was no option for me to use Gemini at all. I used
Aries JPA for quiet a while and I was satisfied with it. As I work with many
colleagues I am responsible for their effectiveness. With Aries JPA I had
the problem that it did not wait for DataSourceFactory services (if db
connection is defined in the persistence.xml) or the DataSource services (if
jta-data-source or non-jta-data-source) is defined. It meant that the bundle
starting order matters when you use Aries JPA.

You can find some more info here:
http://everit.org/osgi/jpa/org.everit.osgi.jpa.container/
https://issues.apache.org/jira/browse/ARIES-840

Is there anyone aware if this issue/behaviour has been taken into account by
Aries team?






--
View this message in context: http://karaf.922171.n3.nabble.com/Aries-JPA-bundle-start-order-issues-tp4028997p4030096.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Aries JPA bundle start order issues

Posted by nseb <se...@hotmail.com>.
Hello,

I just met the problem with version 3.0.0 Trunk, but I think that is listed
probeme aries



--
View this message in context: http://karaf.922171.n3.nabble.com/Aries-JPA-bundle-start-order-issues-tp4028997p4029929.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Aries JPA bundle start order issues

Posted by Bram Pouwelse <br...@pouwelse.com>.
Hi JB,

I'm not using blueprint in my application, the EntityManagerFactory that is
created by Aries JPA is imported using the Felix Dependency Manger.

Regards,
Bram


2013/6/10 Jean-Baptiste Onofré <jb...@nanthrax.net>

> Hi Bram,
>
> do you have several blueprint bundles ?
>
> Regards
> JB
>
>
> On 06/10/2013 07:03 PM, Bram Pouwelse wrote:
>
>> Hi,
>>
>> I've sent the message below to the Aries list last week, but no response
>> yet. I'm wondering if other Karaf users are having the same issue using
>> the JPA feature in Karaf.
>>
>>
>>
>> I'm having some problems using Aries JPA (running on Karaf 2.3.1 and
>> using OpenJPA 2.2.1) .
>>
>> The first problem is that the EntityManagerFactory is created and
>> registered in the service registry even if the DataSource is not
>> available, this causes a problem because other bundles start using the
>> EntityManagerFactory based on it's availability.
>>
>> Is it possible to register the EntityManagerFactory only of the
>> DataSource is available (I'm using JNDI). For now I've added a service
>> dependency on the DataSource to bundles to make them aware of the fact
>> that the EntityManagerFactory can't be used.
>>
>>
>> The second problem I have is that when I restart the bundle that
>> registers the DataSource I get an IllegalStateException [1] when using
>> JPA. The only way to get JPA working again is restarting the JPA
>> Container bundle.
>>
>>
>> The solution for the first issue seems to work pretty well, but it would
>> be really nice to be able to update the DataSource bundle without having
>> to restart the JPA Container.
>>
>> Any idea's on how to overcome the IllegalStateException?
>>
>> Thanks!
>>
>> Bram
>>
>> [1]: Caused by: java.lang.**IllegalStateException: Invalid BundleContext.
>> at
>> org.apache.felix.framework.**BundleContextImpl.**checkValidity(**
>> BundleContextImpl.java:514)
>> at
>> org.apache.felix.framework.**BundleContextImpl.**getServiceReferences(**
>> BundleContextImpl.java:425)
>> at
>> org.apache.aries.jndi.**services.ServiceHelper.**
>> findService(ServiceHelper.**java:375)
>> at
>> org.apache.aries.jndi.**services.ServiceHelper.access$**
>> 500(ServiceHelper.java:66)
>> at
>> org.apache.aries.jndi.**services.ServiceHelper$**JNDIServiceDamper.call(*
>> *ServiceHelper.java:180)
>> at Proxyca2dc362_3bc7_421c_ba6d_**a2b9855d61d6.getConnection(**Unknown
>> Source)
>> at
>> org.apache.aries.jpa.**container.unit.impl.**DelayedLookupDataSource.**
>> getConnection(**DelayedLookupDataSource.java:**36)
>> at
>> org.apache.openjpa.lib.jdbc.**DelegatingDataSource.**getConnection(**
>> DelegatingDataSource.java:110)
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Aries JPA bundle start order issues

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Bram,

do you have several blueprint bundles ?

Regards
JB

On 06/10/2013 07:03 PM, Bram Pouwelse wrote:
> Hi,
>
> I've sent the message below to the Aries list last week, but no response
> yet. I'm wondering if other Karaf users are having the same issue using
> the JPA feature in Karaf.
>
>
>
> I'm having some problems using Aries JPA (running on Karaf 2.3.1 and
> using OpenJPA 2.2.1) .
>
> The first problem is that the EntityManagerFactory is created and
> registered in the service registry even if the DataSource is not
> available, this causes a problem because other bundles start using the
> EntityManagerFactory based on it's availability.
>
> Is it possible to register the EntityManagerFactory only of the
> DataSource is available (I'm using JNDI). For now I've added a service
> dependency on the DataSource to bundles to make them aware of the fact
> that the EntityManagerFactory can't be used.
>
>
> The second problem I have is that when I restart the bundle that
> registers the DataSource I get an IllegalStateException [1] when using
> JPA. The only way to get JPA working again is restarting the JPA
> Container bundle.
>
>
> The solution for the first issue seems to work pretty well, but it would
> be really nice to be able to update the DataSource bundle without having
> to restart the JPA Container.
>
> Any idea's on how to overcome the IllegalStateException?
>
> Thanks!
>
> Bram
>
> [1]: Caused by: java.lang.IllegalStateException: Invalid BundleContext.
> at
> org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:514)
> at
> org.apache.felix.framework.BundleContextImpl.getServiceReferences(BundleContextImpl.java:425)
> at
> org.apache.aries.jndi.services.ServiceHelper.findService(ServiceHelper.java:375)
> at
> org.apache.aries.jndi.services.ServiceHelper.access$500(ServiceHelper.java:66)
> at
> org.apache.aries.jndi.services.ServiceHelper$JNDIServiceDamper.call(ServiceHelper.java:180)
> at Proxyca2dc362_3bc7_421c_ba6d_a2b9855d61d6.getConnection(Unknown Source)
> at
> org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
> at
> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:110)

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