|Spring transactions with aspectj on Virgo [message #660727]
||Mon, 21 March 2011 12:23
Originally posted by: james.ractive.ch|
Our OSGi based application builds on Virgo 2.1.0, Spring 3.0.5,
Eclipselink 2.2 and JPA 2. We have separate bundles for the domain
classes, the JPA services and the web application. We followed the setup
of the greenpages application - more or less. And reading entities from
the embedded H2 database works great.
When trying to insert a new entry into the DB, we figured out that no
transactions have been created in the JPA bundle. Calls to em.persist()
had simply no effect. There was no exception or error in the log, but
the object simply has not been created. Question: Shouldn't there be
some kind of warning that no transaction is present and that persist()
will not do anything?
After a lot of debugging, we changed the transaction mode from "aspectj"
to "proxy" in the spring configuration:
<tx:annotation-driven mode="proxy" />
Now transactions are created and new objects can be persisted.
What do we have to configure so that virgo is able to perform the load
time weaving with aspectj instead of using proxies? I read that virgo
has built-in load time waving capabilities , but I do not find any
useful documentation or examples, how to configure the spring
application to be able to use it.
I also tried to extend the Greepages application to create directory
listing and I ran into the exact same issue. The creation of a new
listing is silently ignored, because no transaction is created.
Let me know if you need more information about the configuration of our
Thanks so far,
http://martinlippert.blogspot.com/2009/04/load-time-weaving- for-spring-dm.html?showComment=1240753860000#c83177281249561 89651
|Re: Spring transactions with aspectj on Virgo [message #663338 is a reply to message #662561]
||Mon, 04 April 2011 16:56
| Dmitry Sklyut
Registered: January 2010
Ok. Here is a solution:|
Change template.mf for greenpages.jpa to this
Bundle-Name: GreenPages JPA
Bundle-Vendor: SpringSource Inc.
1. Added Import-Library for spring lib. This can be cut down to only import required bundles or converted to a a list of Import-Package. I took the brute force approach.
Why? Bundlor only creates import packages for stuff that it can see. It does not deep scan all of the imports that you might need based on the spring config (i.e. <tx:annotation-driven/> and such.
2. Added imports for required aspectj packages.
3. Removed Import-Package for org.springframework packages that are covered by import-library.
Hope this helps.
Powered by FUDForum
. Page generated in 0.07199 seconds