You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Nick Stuart <ni...@gmail.com> on 2014/04/15 22:26:17 UTC

JPA/Open JPA bundle issue.

Hi all, I am having issues getting a very simple JPA example running, and I
am out of ideas on where to head next.

I pretty much have the same problem described here:
http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html
The posts there suggest it should be fixed with 3.0.1 (which I am using),
but it does not appear to be. The very odd thing is that I did get it
working once, but now it's broken again and I don't know why.

I've installed the following features, transaction,jpa,openjpa,jndi, and
jdbc. I can connect to the database through the JDBC commands and all of
that is working just fine. My bundle will not start though.

Here are the log messages I get when installing my bundle:

2014-04-15 16:11:28,366 | WARN  | Local user karaf | container
           | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no
providers available.
2014-04-15 16:11:28,367 | INFO  | Local user karaf | Activator
           | 244 - com.pww.test.demo - 1.0.0.SNAPSHOT | Hello updated!!
2014-04-15 16:11:28,372 | INFO  | Local user karaf | BlueprintContainerImpl
          | 19 - org.apache.aries.blueprint.core - 1.4.0 | Bundle
com.pww.test.demo is waiting for dependencies
[(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name
=test))(objectClass=javax.persistence.EntityManagerFactory))]
2014-04-15 16:11:28,373 | WARN  | Local user karaf | container
           | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no
providers available.

and the out of running `ls | grep persistence`:

karaf@root(jdbc)> ls | grep persistence
[javax.persistence.spi.PersistenceProvider]
 javax.persistence.provider =
org.apache.openjpa.persistence.PersistenceProviderImpl
 javax.persistence.spi.PersistenceProvider =
org.apache.openjpa.persistence.PersistenceProviderImpl

Not really sure what to look at next. Any thoughts or ideas would be great.

Thanks!

Re: JPA/Open JPA bundle issue.

Posted by "Sobkowiak, Krzysztof" <kr...@gmail.com>.
Hi Jamie

When will be this Cookbook available? Is early access of this book
available?

Regards
Krzysztof


On 16.04.2014 01:04, Jamie G. wrote:
> Hi,
>
> The below is from the work in progress of Apache Karaf Cookbook:
>
>  Chapter 7 :: Providing a persistence layer with Apache Aries and OpenJPA.
>
>  Recipe 1:: Installing OpenJPA modules into Apache Karaf.
>  Recipe 2:: Installing Apache Aries modules into Apache Karaf.
>  Recipe 3:: Build a project with persistence layer for deployment in Karaf.
>  Recipe 4:: Build a project with persistence layer and transaction
> support for deployment in Karaf.
>
>  https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter7
>
>  Recipe #3 should be sufficient to get JPA working. Recipe #4 adds JTA.
>
>  The write up to accompany the recipes will be in the forth coming books.
>
> Enjoy,
> Jamie
>
> On Tue, Apr 15, 2014 at 5:56 PM, Nick Stuart <ni...@gmail.com> wrote:
>> Hi all, I am having issues getting a very simple JPA example running, and I
>> am out of ideas on where to head next.
>>
>> I pretty much have the same problem described here:
>> http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html
>> The posts there suggest it should be fixed with 3.0.1 (which I am using),
>> but it does not appear to be. The very odd thing is that I did get it
>> working once, but now it's broken again and I don't know why.
>>
>> I've installed the following features, transaction,jpa,openjpa,jndi, and
>> jdbc. I can connect to the database through the JDBC commands and all of
>> that is working just fine. My bundle will not start though.
>>
>> Here are the log messages I get when installing my bundle:
>>
>> 2014-04-15 16:11:28,366 | WARN  | Local user karaf | container
>> | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no providers
>> available.
>> 2014-04-15 16:11:28,367 | INFO  | Local user karaf | Activator
>> | 244 - com.pww.test.demo - 1.0.0.SNAPSHOT | Hello updated!!
>> 2014-04-15 16:11:28,372 | INFO  | Local user karaf | BlueprintContainerImpl
>> | 19 - org.apache.aries.blueprint.core - 1.4.0 | Bundle com.pww.test.demo is
>> waiting for dependencies
>> [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=test))(objectClass=javax.persistence.EntityManagerFactory))]
>> 2014-04-15 16:11:28,373 | WARN  | Local user karaf | container
>> | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no providers
>> available.
>>
>> and the out of running `ls | grep persistence`:
>>
>> karaf@root(jdbc)> ls | grep persistence
>> [javax.persistence.spi.PersistenceProvider]
>>  javax.persistence.provider =
>> org.apache.openjpa.persistence.PersistenceProviderImpl
>>  javax.persistence.spi.PersistenceProvider =
>> org.apache.openjpa.persistence.PersistenceProviderImpl
>>
>> Not really sure what to look at next. Any thoughts or ideas would be great.
>>
>> Thanks!

-- 
Krzysztof Sobkowiak

JEE & OSS Architect | Technical Architect @ Capgemini
Capgemini <http://www.pl.capgemini.com/> | Software Solutions Center
<http://www.pl.capgemini-sdm.com/> | Wroclaw
e-mail: krzys.sobkowiak@gmail.com <ma...@gmail.com> |
Twitter: @KSobkowiak

Re: JPA/Open JPA bundle issue.

Posted by "Jamie G." <ja...@gmail.com>.
Hi,

The below is from the work in progress of Apache Karaf Cookbook:

 Chapter 7 :: Providing a persistence layer with Apache Aries and OpenJPA.

 Recipe 1:: Installing OpenJPA modules into Apache Karaf.
 Recipe 2:: Installing Apache Aries modules into Apache Karaf.
 Recipe 3:: Build a project with persistence layer for deployment in Karaf.
 Recipe 4:: Build a project with persistence layer and transaction
support for deployment in Karaf.

 https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter7

 Recipe #3 should be sufficient to get JPA working. Recipe #4 adds JTA.

 The write up to accompany the recipes will be in the forth coming books.

Enjoy,
Jamie

On Tue, Apr 15, 2014 at 5:56 PM, Nick Stuart <ni...@gmail.com> wrote:
> Hi all, I am having issues getting a very simple JPA example running, and I
> am out of ideas on where to head next.
>
> I pretty much have the same problem described here:
> http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html
> The posts there suggest it should be fixed with 3.0.1 (which I am using),
> but it does not appear to be. The very odd thing is that I did get it
> working once, but now it's broken again and I don't know why.
>
> I've installed the following features, transaction,jpa,openjpa,jndi, and
> jdbc. I can connect to the database through the JDBC commands and all of
> that is working just fine. My bundle will not start though.
>
> Here are the log messages I get when installing my bundle:
>
> 2014-04-15 16:11:28,366 | WARN  | Local user karaf | container
> | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no providers
> available.
> 2014-04-15 16:11:28,367 | INFO  | Local user karaf | Activator
> | 244 - com.pww.test.demo - 1.0.0.SNAPSHOT | Hello updated!!
> 2014-04-15 16:11:28,372 | INFO  | Local user karaf | BlueprintContainerImpl
> | 19 - org.apache.aries.blueprint.core - 1.4.0 | Bundle com.pww.test.demo is
> waiting for dependencies
> [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=test))(objectClass=javax.persistence.EntityManagerFactory))]
> 2014-04-15 16:11:28,373 | WARN  | Local user karaf | container
> | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no providers
> available.
>
> and the out of running `ls | grep persistence`:
>
> karaf@root(jdbc)> ls | grep persistence
> [javax.persistence.spi.PersistenceProvider]
>  javax.persistence.provider =
> org.apache.openjpa.persistence.PersistenceProviderImpl
>  javax.persistence.spi.PersistenceProvider =
> org.apache.openjpa.persistence.PersistenceProviderImpl
>
> Not really sure what to look at next. Any thoughts or ideas would be great.
>
> Thanks!

Re: JPA/Open JPA bundle issue.

Posted by Christian Schneider <ch...@die-schneider.net>.
I think the silent failures are related to 
https://issues.apache.org/jira/browse/ARIES-1160 .
The problem is that aries currently does not log the exceptions the 
persistence provider throws.
In many cases this leads to the probblem that the EntityManagerFactory 
can not be found but no error is displayed.
Btw. in this case it sometimes helps restarting aries jpa container 
bundle as it then logs an error.

So I hope with the next aries jpa version we will have better error 
reporting by default.

Christian


On 16.04.2014 15:02, nstuart wrote:
> Ok, just got it working. One exception caused me to double check some
> settings, when I logged out of the karaf console I got:
>
> java.lang.IllegalStateException: No persistence units defined for bundle
> com.pww.test.demo/1.0.0.SNAPSHOT.
> 	at
> org.apache.aries.jpa.container.unit.impl.ManagedPersistenceUnitInfoFactoryImpl.destroyPersistenceBundle(ManagedPersistenceUnitInfoFactoryImpl.java:60)
> 	at
> org.apache.aries.jpa.container.impl.PersistenceBundleManager.removedBundle(PersistenceBundleManager.java:313)
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerRemoved(BundleHookBundleTracker.java:513)
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerRemoved(BundleHookBundleTracker.java:433)
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.untrack(BundleHookBundleTracker.java:834)
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker.close(BundleHookBundleTracker.java:196)
> 	at
> org.apache.aries.util.tracker.RecursiveBundleTracker.close(RecursiveBundleTracker.java:120)
> 	at
>     ....
>
> And I thought that was odd as I know I have one defined. I went and checked
> my persistence.xml and found a wrong version and mismatch name.
>
> &lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
>               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>               version="2.0"&gt;  (notice 2.0)
>
> Apparently in my random thrashing for other things this got changed. I
> changed it back to 1.0 and made sure everything matched, and magically it
> works now. However, that not so good part is that it failed silently and
> also that Christian's example was exhibiting the same problem, and all his
> stuff matched up. (also with no other apparent changes that example is
> working now as well)
>
> Bah, anyways, its work, thanks for making be look and double check items,
> not sure if anything more useful could be added to the logs for this to make
> the process easier, besides the issue that is already closed that was
> mentioned earlier.
>
> Thanks again!
> -Nick
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/JPA-Open-JPA-bundle-issue-tp4032784p4032801.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: JPA/Open JPA bundle issue.

Posted by nstuart <ni...@gmail.com>.
Ok, just got it working. One exception caused me to double check some
settings, when I logged out of the karaf console I got:

java.lang.IllegalStateException: No persistence units defined for bundle
com.pww.test.demo/1.0.0.SNAPSHOT.
	at
org.apache.aries.jpa.container.unit.impl.ManagedPersistenceUnitInfoFactoryImpl.destroyPersistenceBundle(ManagedPersistenceUnitInfoFactoryImpl.java:60)
	at
org.apache.aries.jpa.container.impl.PersistenceBundleManager.removedBundle(PersistenceBundleManager.java:313)
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerRemoved(BundleHookBundleTracker.java:513)
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerRemoved(BundleHookBundleTracker.java:433)
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.untrack(BundleHookBundleTracker.java:834)
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker.close(BundleHookBundleTracker.java:196)
	at
org.apache.aries.util.tracker.RecursiveBundleTracker.close(RecursiveBundleTracker.java:120)
	at 
   ....

And I thought that was odd as I know I have one defined. I went and checked
my persistence.xml and found a wrong version and mismatch name.

&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             version="2.0"&gt;  (notice 2.0)

Apparently in my random thrashing for other things this got changed. I
changed it back to 1.0 and made sure everything matched, and magically it
works now. However, that not so good part is that it failed silently and
also that Christian's example was exhibiting the same problem, and all his
stuff matched up. (also with no other apparent changes that example is
working now as well) 

Bah, anyways, its work, thanks for making be look and double check items,
not sure if anything more useful could be added to the logs for this to make
the process easier, besides the issue that is already closed that was
mentioned earlier.

Thanks again!
-Nick




--
View this message in context: http://karaf.922171.n3.nabble.com/JPA-Open-JPA-bundle-issue-tp4032784p4032801.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: JPA/Open JPA bundle issue.

Posted by nstuart <ni...@gmail.com>.
Thanks for the info Christian, I tried at first with hibernate and found that
the jpa 2.1 version might be the issue so I went back to OpenJPA. I also
made sure I used the 2.2.2 version as it seems like that had been a bit
better tested.

My bundle does have the <Meta-Persistence> info it, here is the generated
version that Maven spits out:

Manifest-Version: 1.0
Bnd-LastModified: 1397592346859
Build-Jdk: 1.8.0
Built-By: nick
Bundle-Activator: com.pww.test.osgi.Activator
Bundle-Blueprint: OSGI-INF/blueprint/config.xml
Bundle-ManifestVersion: 2
Bundle-Name: demo OSGi Bundle
Bundle-SymbolicName: com.pww.test.demo
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.pww.test.osgi.services;uses:="com.pww.test.osgi.doma
 in";version="1.0.0.SNAPSHOT",com.pww.test.osgi.domain;uses:="javax.pers
 istence";version="1.0.0.SNAPSHOT"
Export-Service: com.pww.test.osgi.services.HelloWorldService
Import-Package: javax.persistence;version="[1.0.0,2.0.0]",com.pww.test.o
 sgi.domain,com.pww.test.osgi.services,javax.annotation,org.osgi.framewo
 rk;version="[1.6,2)",org.osgi.service.blueprint;version="[1.0.0,2.0.0)"
 ,org.slf4j;version="[1.7,2)"
Meta-Persistence: META-INF/persistence.xml
Tool: Bnd-2.1.0.20130426-122213

I tried setting the log to DEBUG, but was a unable find any useful
information from there (could be I just don't know what to look for). Also,
I tried the example you have as well at
http://www.liquid-reality.de/display/liquid/2012/01/13/Apache+Karaf+Tutorial+Part+6+-+Database+Access
and have the same issue.

The only thing I haven't tried is blowing away my Karaf install and trying
from scratch, but I would really like to understand whats 'wrong' with my
current setup before I go that route.

-Nick



--
View this message in context: http://karaf.922171.n3.nabble.com/JPA-Open-JPA-bundle-issue-tp4032784p4032800.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: JPA/Open JPA bundle issue.

Posted by "Jamie G." <ja...@gmail.com>.
Hi Krzysztof,

We're hoping to have the book out in a few months. There is no early
access program :(

-Jamie

On Wed, Apr 16, 2014 at 4:27 AM, Christian Schneider
<ch...@die-schneider.net> wrote:
> What the log says is that your bundle requires an EntityManagerFactory for
> the persistence unit test but can not find one.
>
> Unfortunately there are several possible reasons and aries jpa does not show
> good errors.
>
> 1. Possibly your Manifest does not contain the Meta-Persistence entry.
>
> Make sure you have this in the maven bundle plugin config:
> <Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
>
> 2. There are no providers available hints that aries jpa does not find a
> PersitenceProvider service. I had this with hibernate 3.3.x. It published a
> service but the
> with the jpa 2.1 version of the package. So aries jpa did not see it. Check
> the headers of openjpa and aries jpa container if this is the case.
> JB told me he is preparing a patch for aries jpa to have a wider import
> range for the jpa spec packages. Until then make sure you use an older
> version
> of the persistence provider that works with jpa 2.0.
>
> 3. Possibly the persistence context is found but there is an error
> initializing it. Aries jpa swallows these errors. There is a patch in this
> issue that solves this:
> https://issues.apache.org/jira/browse/ARIES-1160
>
> From the log It think variant 2 is the most probable. I just tried to
> install jpa and openjpa in karaf 3.0.1 but it seems to use jpa 2.0 so that
> speaks against this case.
>
> Christian
>
>
>
> On 15.04.2014 22:26, Nick Stuart wrote:
>
> Hi all, I am having issues getting a very simple JPA example running, and I
> am out of ideas on where to head next.
>
> I pretty much have the same problem described here:
> http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html
> The posts there suggest it should be fixed with 3.0.1 (which I am using),
> but it does not appear to be. The very odd thing is that I did get it
> working once, but now it's broken again and I don't know why.
>
> I've installed the following features, transaction,jpa,openjpa,jndi, and
> jdbc. I can connect to the database through the JDBC commands and all of
> that is working just fine. My bundle will not start though.
>
> Here are the log messages I get when installing my bundle:
>
> 2014-04-15 16:11:28,366 | WARN  | Local user karaf | container
> | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no providers
> available.
> 2014-04-15 16:11:28,367 | INFO  | Local user karaf | Activator
> | 244 - com.pww.test.demo - 1.0.0.SNAPSHOT | Hello updated!!
> 2014-04-15 16:11:28,372 | INFO  | Local user karaf | BlueprintContainerImpl
> | 19 - org.apache.aries.blueprint.core - 1.4.0 | Bundle com.pww.test.demo is
> waiting for dependencies
> [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=test))(objectClass=javax.persistence.EntityManagerFactory))]
> 2014-04-15 16:11:28,373 | WARN  | Local user karaf | container
> | 114 - org.apache.aries.jpa.container - 1.0.0 | There are no providers
> available.
>
> and the out of running `ls | grep persistence`:
>
> karaf@root(jdbc)> ls | grep persistence
> [javax.persistence.spi.PersistenceProvider]
>  javax.persistence.provider =
> org.apache.openjpa.persistence.PersistenceProviderImpl
>  javax.persistence.spi.PersistenceProvider =
> org.apache.openjpa.persistence.PersistenceProviderImpl
>
> Not really sure what to look at next. Any thoughts or ideas would be great.
>
> Thanks!
>
>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com

Re: JPA/Open JPA bundle issue.

Posted by Christian Schneider <ch...@die-schneider.net>.
What the log says is that your bundle requires an EntityManagerFactory 
for the persistence unit test but can not find one.

Unfortunately there are several possible reasons and aries jpa does not 
show good errors.

1. Possibly your Manifest does not contain the Meta-Persistence entry.

Make sure you have this in the maven bundle plugin config:
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>

2. There are no providers available hints that aries jpa does not find a 
PersitenceProvider service. I had this with hibernate 3.3.x. It 
published a service but the
with the jpa 2.1 version of the package. So aries jpa did not see it. 
Check the headers of openjpa and aries jpa container if this is the case.
JB told me he is preparing a patch for aries jpa to have a wider import 
range for the jpa spec packages. Until then make sure you use an older 
version
of the persistence provider that works with jpa 2.0.

3. Possibly the persistence context is found but there is an error 
initializing it. Aries jpa swallows these errors. There is a patch in 
this issue that solves this:
https://issues.apache.org/jira/browse/ARIES-1160

 From the log It think variant 2 is the most probable. I just tried to 
install jpa and openjpa in karaf 3.0.1 but it seems to use jpa 2.0 so 
that speaks against this case.

Christian


On 15.04.2014 22:26, Nick Stuart wrote:
> Hi all, I am having issues getting a very simple JPA example running, 
> and I am out of ideas on where to head next.
>
> I pretty much have the same problem described here:
> http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html
> The posts there suggest it should be fixed with 3.0.1 (which I am 
> using), but it does not appear to be. The very odd thing is that I did 
> get it working once, but now it's broken again and I don't know why.
>
> I've installed the following features, transaction,jpa,openjpa,jndi, 
> and jdbc. I can connect to the database through the JDBC commands and 
> all of that is working just fine. My bundle will not start though.
>
> Here are the log messages I get when installing my bundle:
>
> 2014-04-15 16:11:28,366 | WARN  | Local user karaf | container         
>                | 114 - org.apache.aries.jpa.container - 1.0.0 | There 
> are no providers available.
> 2014-04-15 16:11:28,367 | INFO  | Local user karaf | Activator         
>                | 244 - com.pww.test.demo - 1.0.0.SNAPSHOT | Hello 
> updated!!
> 2014-04-15 16:11:28,372 | INFO  | Local user karaf | 
> BlueprintContainerImpl           | 19 - 
> org.apache.aries.blueprint.core - 1.4.0 | Bundle com.pww.test.demo is 
> waiting for dependencies 
> [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name 
> <http://osgi.unit.name/>=test))(objectClass=javax.persistence.EntityManagerFactory))]
> 2014-04-15 16:11:28,373 | WARN  | Local user karaf | container         
>                | 114 - org.apache.aries.jpa.container - 1.0.0 | There 
> are no providers available.
>
> and the out of running `ls | grep persistence`:
>
> karaf@root(jdbc)> ls | grep persistence
> [javax.persistence.spi.PersistenceProvider]
>  javax.persistence.provider = 
> org.apache.openjpa.persistence.PersistenceProviderImpl
>  javax.persistence.spi.PersistenceProvider = 
> org.apache.openjpa.persistence.PersistenceProviderImpl
>
> Not really sure what to look at next. Any thoughts or ideas would be 
> great.
>
> Thanks!


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com