Hi,
@Jean-Baptiste Onofré, François: I can confirm, issues is fixed now. I can
get JPA example working. I see output in Karaf Shell.
but :)
What was the fix ( so I can understand what was wrong, for any future case,
other projects ):
I
see
examples/karaf-jpa-example/karaf-jpa-example-features/src/main/feature/feature.xml
( I guess this is most of the fix )
<feature name="karaf-jpa-example-common" version="${project.version}">
<feature>transaction</feature>
<feature>transaction</feature>
+ <feature>jndi</feature>
<feature>pax-jdbc-config</feature>
<feature>pax-jdbc-config</feature>
<feature>pax-jdbc-h2</feature>
<feature>pax-jdbc-h2</feature>
<feature>pax-jdbc-pool-dbcp2</feature>
<feature>pax-jdbc-pool-dbcp2</feature>
<feature>jdbc</feature> <feature>jdbc</feature>
<feature version="[2,3)">jpa</feature> <feature
version="[2,3)">jpa</feature>
- <feature version="6.0.10.Final">hibernate</feature>
+ <feature version="[5,6)">hibernate</feature>
+ <capability>
+
osgi.service;objectClass=javax.persistence.spi.PersistenceProvider;effective:=active;javax.persistence.provider=org.hibernate.jpa.HibernatePersistenceProvider
+ </capability>
</feature> </feature>
So this three lines:
+ <capability>
+
osgi.service;objectClass=javax.persistence.spi.PersistenceProvider;effective:=active;javax.persistence.provider=org.hibernate.jpa.HibernatePersistenceProvider
+ </capability>
I have similar Bundle structure, but I have dedicated Bundle for DataSource
setup/configuration. How do I translate this "Feature DSL" to "Blueprint
DSL" ==> How would this translate into Blueprint XML?
So changes look they make sense but, this is first time I see this to be
defined so explicit. This was my original complaint, as it always looked
like this piece of code was missing ( also in other available online
examples ).
I also guess "effective:=active;" is important ( as I read the "I've
explained it already three times" forum post ) ( FW:
http://karaf.922171.n3.nabble.com/What-does-effective-active-mean-td4047770.html
)
Well, thank you both very much. Saved me tons of headache.
Kind Regards,
Miroslav
2018-07-24 20:51 GMT+02:00 Jean-Baptiste Onofré <[email protected]>:
> Hi,
>
> François just fixed the JPA example of the DEV_GUIDE branch.
>
> I will add the corresponding examples itests tomorrow.
>
> Regards
> JB
>
> On 20/07/2018 16:17, Miroslav Beranič wrote:
> > Hi,
> >
> > I've upgraded my environment from ServiceMix 7.1.0-SNAPSHOT ( running
> > Karaf 4.0.9 ) to Karaf 4.1.x ( GitHub ) branch and later on I've
> > experimented with version 4.2.x.
> > I was using linked linkes from Karaf home page (
> > https://karaf.apache.org/documentation.html ) to GitHub Examples - for
> JPA.
> >
> > My main task is to get JPA 2 up and running, but I fail to do so.
> >
> > So on provided examples Github repository:
> > https://github.com/jbonofre/karaf/tree/DEV_GUIDE/examples/
> karaf-jpa-example
> >
> > I've tested with Karaf 4.1.x and 4.2.x and in both version, Examples for
> > JPA do now work - for me.
> >
> > For Karaf 4.2.x I've created PasteBin outputs ( please see ):
> > 1.) https://pastebin.com/eJybVNhn
> > 2.) https://pastebin.com/W2UhihdR
> >
> > In examples, I've noted that there is a reference to Hibernate
> > 6.0.10.Final - this version is not released yet ( hibernate.org
> > <http://hibernate.org> ), so I guess this is a wrong version, or ? as I
> > see Karaf has build-in support for Hibernate 5.2.9.Final.
> >
> > https://github.com/jbonofre/karaf/blob/DEV_GUIDE/examples/
> karaf-jpa-example/karaf-jpa-example-features/src/main/feature/feature.xml
> >
> > For Hibernate version I am looking at:
> > https://github.com/apache/karaf/blob/master/pom.xml
> > <hibernate.version>5.2.9.Final</hibernate.version>
> >
> > So what I did was:
> >
> > 1.) checked out Karaf 4.1.x from Github
> > 2.) checked out Karaf Examples ( DEV_GUIDE branch from Github )
> >
> > 3.) Build Karaf with Maven: mvn -Pfastinstall and started Karaf with
> > ./bin/karaf debug
> > 4.) Build Karaf Examples ( changed version of Hibernate from
> > 6.0.10.Final to 5.2.9.Final )
> >
> > Read instruction from:
> > https://github.com/jbonofre/karaf/blob/DEV_GUIDE/examples/
> karaf-jpa-example/README.md
> >
> > 5.) feature:repo-add
> > mvn:org.apache.karaf.examples/karaf-jpa-example-features/4.
> 2.1-SNAPSHOT/xml
> > 6.) feature:install karaf-jpa-example-datasource
> > 7.) feature:install karaf-jpa-example-provider
> >
> > Fail:
> >
> > Error executing command: Unable to resolve root: missing requirement
> > [root] osgi.identity; osgi.identity=karaf-jpa-example-provider;
> > type=karaf.feature; version="[4.2.1.SNAPSHOT,4.2.1.SNAPSHOT]";
> > filter:="(&(osgi.identity=karaf-jpa-example-provider)(
> type=karaf.feature)(version>=4.2.1.SNAPSHOT)(version<=4.2.1.SNAPSHOT))"
> > [caused by: Unable to resolve karaf-jpa-example-provider/4.2.1.SNAPSHOT:
> > missing requirement [karaf-jpa-example-provider/4.2.1.SNAPSHOT]
> > osgi.identity;
> > osgi.identity=org.apache.karaf.examples.karaf-jpa-example-provider;
> > type=osgi.bundle; version="[4.2.1.SNAPSHOT,4.2.1.SNAPSHOT]";
> > resolution:=mandatory [caused by: Unable to resolve
> > org.apache.karaf.examples.karaf-jpa-example-provider/4.2.1.SNAPSHOT:
> > missing requirement
> > [org.apache.karaf.examples.karaf-jpa-example-provider/4.2.1.SNAPSHOT]
> > osgi.service; objectClass=javax.persistence.spi.PersistenceProvider;
> > javax.persistence.provider=org.hibernate.jpa.
> HibernatePersistenceProvider;
> > effective:=active]]
> >
> > I am using Linux x64, Oracle Java 8 172 x64.
> >
> > What I am doing wrong. I've mixed different version of Hibernate, Karaf,
> > ... and noting. Always some more or less strange error.
> >
> > Plus there is an issue: what version of maven-bundle-plugin should/must
> > be used? I've tried 3.01 and 3.2.0. When I use 3.0.1 I have to update
> > <Import-Package> if I use 3.2.0 I get error that javassist is not
> resolved:
> >
> > Error executing command: Unable to resolve root: missing requirement
> > [root] osgi.identity; osgi.identity=. ... osgi.wiring.package;
> > filter:="(&(osgi.wiring.package=javassist.util.proxy)(
> version>=3.22.0)(!(version>=4.0.0)))"]]]
> >
> >
> >
> > So all in all I can not and did not find and singe point of truth what
> > is valid example or way of doing JPA 2 with Hibernate. I guess I am
> > doing something wrong as all examples make it so simple but ... no luck.
> > All I did is clean ( new computer - virtual ) checkout from git, build
> > and deploy - and fail.
> >
> > I would like to migrate existing code using JPA 1 to JPA 2 ( 2.2 ? ) but
> > ... this is difficult task to complete ( this is after one week of pain
> > and frustration ).
> >
> > I've done examples from https://github.com/cschneider/Karaf-Tutorial
> > also, but no luck. More-or-less same problems.
> >
> >
> > 1.) What versions of Maven plugins should I use?
> > 2.) What versions of JPA?
> > 3.) What versions of Hibernate?
> > 4.) What example should I follow ( URL / Git and branch ) ?
> >
> >
> > This are my top questions.
> >
> >
> > Kind Regards,
> > Miroslav
> >
> >
> >
> > --
> > Miroslav Beranič
> > MIBESIS
> > +386(0)40/814-843
> > [email protected] <mailto:[email protected]>
> > http://www.mibesis.si
>
--
Miroslav Beranič
MIBESIS
+386(0)40/814-843
[email protected]
http://www.mibesis.si