Hi Achim,
I point people to the my example as it is the easiest way to get a
complete picture how to do it.
The transition is to change the namespaces, use the enable element and
add the annoations. It is a work of 10 minutes for a typical bundle. The
example show how it should look like.
I also documentated how to do jpa at the Aries website.
http://aries.apache.org/modules/jpaproject.html
Recently I also added examples for blueprint and ds for jpa:
https://github.com/apache/aries/tree/trunk/jpa/examples/tasklist-blueprint
So all the necessary documentation is there. Please try to read the
documentation before you complain it is bad.
I agree that it would be nicer to support the old namespace. In
transaction 2.0.0 I learned how to do it without a breakage. I am not
against supporting the old namespace too but it should be done in a
separate bundle to not let the old complexity creep into the new code again.
If you want to work on it I will help to apply the changes. Currently
this is not a priority for my own development though as I think the
transition is not that difficult. People who changed to the new
namespace like it as far as I can tell.
Christian
Am 25.11.2015 um 08:41 schrieb Achim Nierbeck:
Christian,
it's nice that you have a tutorial and what-so-ever about it but if
it's not in the docs it mere doesn't exist.
Till now I counted about the 5th complaint about JPA not working with
Karaf 4 any more.
So please stop advertising your blog but help people to actually get
it going again. AFAIK you did decide on
neglecting on supporting the "old" transaction style for blueprint in
the current version, so please
show a way for easy transition.
@JB do you see a way of having the Karaf 3.0 defaults again.
So people can actually use JPA/JTA stuff as in 3.0?
regards, Achim
2015-11-25 8:05 GMT+01:00 Christian Schneider <[email protected]
<mailto:[email protected]>>:
The old namespace for jpa is not supported anymore by Aries JPA
2.x. Can you try with the new namespaces like used in my
tutorial code? You will need to use annoations then.
For transactions you can still use the old namespace but I would
also recommend the new one.
Christian
On 24.11.2015 17:22, Jason Reilly wrote:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
default-activation="eager">
<bean id="alignmentDAOImpl"
class="org.renci.hearsay.dao.jpa.AlignmentDAOImpl">
<tx:transaction method="*" value="Required" />
<jpa:context property="entityManager" unitname="hearsay" />
</bean>
...snip....
<service ref="alignmentDAOImpl"
interface="org.renci.hearsay.dao.AlignmentDAO" />
...snip....
<bean id="hearsayDAOBeanService"
class="org.renci.hearsay.dao.HearsayDAOBean">
<property name="alignmentDAO" ref="alignmentDAOImpl" />
...snip....
</bean>
<service ref="hearsayDAOBeanService"
interface="org.renci.hearsay.dao.HearsayDAOBeanService" />
</blueprint>
On 11/24/2015 11:19 AM, Jean-Baptiste Onofré wrote:
Can you share the blueprint XML in your hearsay-dao-jpa
bundle ?
On 11/24/2015 04:57 PM, Jason Reilly wrote:
I tried 1.0.0 for those urls & here is the error message:
2015-11-24 10:56:12,317 | INFO | pool-47-thread-1 |
BlueprintContainerImpl | 34 -
org.apache.aries.blueprint.core
- 1.4.5 | Bundle hearsay-dao-jpa/0.0.46.
<http://0.0.46.>SNAPSHOT is waiting for
namespace handlers
[http://aries.apache.org/xmlns/transactions/v1.0.0,
http://aries.apache.org/xmlns/jpa/v1.0.0]
On 11/24/2015 10:55 AM, Jason Reilly wrote:
I gave that a whirl...here are the details:
In my pom.xml which builds my custom Karaf
distribution:
...snip..
<bootFeatures>
<feature>feature</feature>
<feature>shell</feature>
<feature>bundle</feature>
<feature>config</feature>
<feature>diagnostic</feature>
<feature>instance</feature>
<feature>jaas</feature>
<feature>log</feature>
<feature>package</feature>
<feature>service</feature>
<feature>system</feature>
<feature>ssh</feature>
<feature>management</feature>
<feature>deployer</feature>
<feature>obr</feature>
<feature>http</feature>
<feature>war</feature>
<feature>jetty</feature>
<feature>scr</feature>
<feature>jndi</feature>
<feature>aries-blueprint</feature>
<feature>cxf</feature>
<feature>jdbc</feature>
<feature>transaction-api/1.1.0</feature>
<feature>openjpa/${openjpa.version}</feature>
<feature>spring/${spring.version}_1</feature>
<feature>spring-orm/${spring.version}_1</feature>
<feature>spring-web/${spring.version}_1</feature>
<feature>hearsay-commons</feature>
<!-- <feature>hearsay-dao</feature> -->
</bootFeatures>
...snip...
From the Karaf prompt:
karaf@root()> list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
--------------------------------------------------------------------------------------
8 | Active | 80 | 1.5.0 | OPS4J
Base - Lang
9 | Active | 80 | 1.5.0 | OPS4J
Base - Service
Provider Access
10 | Active | 80 | 0.7.0 | OPS4J
Pax JDBC Generic
Driver Extender
11 | Active | 80 | 0.7.0 | OPS4J
Pax JDBC Config
12 | Active | 80 | 1.8.1 | OPS4J
Pax Swissbox :: OSGi Core
13 | Active | 80 | 1.8.1 | OPS4J
Pax Swissbox :: Extender
14 | Active | 80 | 1.8.1 | OPS4J
Pax Swissbox :: Lifecycle
15 | Active | 80 | 1.0.0.201505202023 |
org.osgi:org.osgi.service.jdbc
16 | Active | 80 | 2.4.1 |
Jackson-annotations
17 | Active | 80 | 2.4.1 | Jackson-core
18 | Active | 80 | 2.4.1 |
jackson-databind
19 | Active | 80 | 2.4.1 |
Jackson-JAXRS-base
20 | Active | 80 | 2.4.1 |
Jackson-JAXRS-JSON
21 | Active | 80 | 2.4.1 |
Jackson-module-JAXB-annotations
27 | Active | 80 | 1.1.0.Final | Bean
Validation API
49 | Active | 80 | 1.8.3 | Commons
BeanUtils
50 | Active | 80 | 1.2 | Commons CLI
52 | Active | 80 | 3.2.1 | Commons
Collections
53 | Active | 80 | 4.0.0 | Apache
Commons Collections
54 | Active | 80 | 1.4.0 | Commons
Compress
55 | Active | 80 | 0.5 | Commons
Discovery
56 | Active | 80 | 1.3.1 | Commons
Email
57 | Active | 80 | 2.4.0 | Commons IO
59 | Active | 80 | 3.4.0 | Apache
Commons Lang
60 | Active | 80 | 3.5.0 | Apache
Commons Math
61 | Active | 80 | 3.3.0 | Commons Net
62 | Active | 80 | 1.5.6 | Commons Pool
105 | Active | 80 | 1.1.1 |
geronimo-jms_1.1_spec
106 | Active | 80 | 1.1 | Apache
Geronimo JSR-317 JPA
2.0 Spec API
107 | Active | 80 | 1.1.1 |
geronimo-jta_1.1_spec
123 | Active | 80 | 4.0.3 | Apache
Karaf :: JDBC :: Core
137 | Active | 80 | 2.0.9 | Apache
MINA Core
139 | Active | 80 | 2.4.0 | OpenJPA
Aggregate Jar
141 | Active | 80 | 1.7.0.6 | Apache
ServiceMix :: Bundles
:: ant
143 | Active | 80 | 1.7.4.1 | Apache
ServiceMix :: Bundles
:: aspectj
145 | Active | 80 | 1.4.0.3 | Apache
ServiceMix :: Bundles
:: commons-dbcp
154 | Active | 80 | 1.14.1.1 | Apache
ServiceMix :: Bundles
:: serp
162 | Active | 80 | 1.3.2.RELEASE_2 | Apache
ServiceMix :: Bundles
:: spring-ldap
180 | Active | 80 | 4.3.0 | Apache
XBean :: ASM 5 shaded
(repackaged)
229 | Active | 80 | 9.4.0.build-1205 |
PostgreSQL JDBC Driver JDBC41
230 | Active | 80 | 2.2.7.RELEASE | Spring
Batch Core
231 | Active | 80 | 2.2.7.RELEASE | Spring
Batch Infrastructure
232 | Active | 80 | 1.4.1.RELEASE | Spring
Data Commons Core
237 | Active | 80 | 3.2.8.RELEASE | Spring
Security LDAP
242 | Active | 80 | 0.0.1 | RENCI ::
OSGi :: Bundle ::
XZ 1.0
At this point, everything looks good. Then I
install the hearsay-dao
feature & the list command shows the following
additional bundles:
243 | Active | 80 | 0.0.46.SNAPSHOT |
Hearsay :: DAO :: API
244 | GracePeriod | 80 | 0.0.46.SNAPSHOT |
Hearsay :: DAO :: JPA
245 | Active | 80 | 0.0.46.SNAPSHOT |
Hearsay :: Datasource
From the karaf.log file, I see the following:
2015-11-24 10:51:15,958 | INFO | pool-48-thread-1 |
BlueprintContainerImpl | 34 -
org.apache.aries.blueprint.core - 1.4.5 | Bundle
hearsay-dao-jpa/0.0.46. <http://0.0.46.>SNAPSHOT
is waiting for namespace handlers
[http://aries.apache.org/xmlns/transactions/v1.1.0,
http://aries.apache.org/xmlns/jpa/v1.1.0]
Should the Aries transaction/jpa versions be 1.0.0
instead?
Thanks,
Jason
On 11/24/2015 10:22 AM, Jean-Baptiste Onofré wrote:
Basically, you should have transaction-api
1.1.0 installed (not
1.2.0) and no transaction/1.3.0 feature
installed for OpenJPA.
Regards
JB
On 11/24/2015 04:13 PM, Jason Reilly wrote:
Hi JB,
I was using what I could find
out-of-the-box....which I think is
transaction/1.3.0. <http://1.3.0.> I
didn't know of a transaction 2.x feature.
What is
the repo for that?
Regards,
Jason
On 11/24/2015 10:05 AM, Jean-Baptiste
Onofré wrote:
Hi Jason,
did you install transaction 2.x feature ?
Regards
JB
On 11/24/2015 03:41 PM, Jason Reilly
wrote:
Hi all,
I am trying to migrate an
application to Karaf 4.0.3 & am using
Java8. I
have tried a few permutations of
persistence providers (hibernate,
openjpa, & eclipselink). I got
Hibernate to work, but ran into a
number
of problems (like not having all
the collections in a
@NamedEntityGraph
loaded & this bug:
https://hibernate.atlassian.net/browse/HHH-9270).
Wanting to continue with JPA 2.1,
I tried out eclipselink. One of the
problems I had with eclipselink
was the following:
2015-11-23 16:28:10,754 | INFO |
rint Extender: 3 |
BlueprintContainerImpl |
31 -
org.apache.aries.blueprint.core
- 1.4.5 | Bundle
hearsay-dao-jpa/0.0.46.
<http://0.0.46.>SNAPSHOT is
waiting for
namespace handlers
[http://aries.apache.org/xmlns/transactions/v2.0.0]
I have transaction & jpa features
installed, but the hearsay-dao-jpa
bundle is never activated when I
use a blueprint xml file to register
the services. When I use the
pax-cdi annotations (as in Christian's
KarafTutorial example), the
hearsay-dao-jpa bundle is
activated, but
throws an NPE on
getEntityManager() despite using the
PersistentContext
annotation. I think this might be
related to the Aries JPA 2.2.0
problem mentioned in another
thread (Problem with JPA 2.2.0 in
Karaf
4.0.2).
When I try openjpa/2.4.0 & JPA
2.0, the openjpa bundle is in a
resolved
state. When I try to start that
bundle the following is thrown:
ERROR: Bundle
org.apache.aries.jpa.container
[55] EventDispatcher:
Error
during dispatch.
(java.lang.NoClassDefFoundError:
javax/transaction/Synchronization)
java.lang.NoClassDefFoundError:
javax/transaction/Synchronization
However, the packages are available:
karaf@root()> exports | grep
javax.transaction
javax.transaction.xa
| 0.0.0 | 0 |
org.apache.felix.framework
javax.transaction.xa
| 1.1.0 | 122 |
org.apache.geronimo.specs.geronimo-jta_1.1_spec
javax.transaction.xa
| 1.2.0 | 256 |
javax.transaction-api
javax.transaction
| 0.0.0 | 0 |
org.apache.felix.framework
javax.transaction
| 1.1.0 | 122 |
org.apache.geronimo.specs.geronimo-jta_1.1_spec
javax.transaction
| 1.2.0 | 256 |
javax.transaction-api
I also see the following in the
log after messing with which
transaction-api/persistence-api
features I have installed:
Caused by:
java.lang.NoClassDefFoundError:
javax/transaction/SystemException
at
org.apache.openjpa.persistence.osgi.PersistenceActivator.start(PersistenceActivator.java:61)
Before reverting back to Karaf
3.0.5...is there anything else I can
try? Suggestions?
Thanks,
Jason
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
Software Architect / Project Manager / Scrum Master