Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Spring transactions with aspectj on Virgo
Spring transactions with aspectj on Virgo [message #660727] Mon, 21 March 2011 12:23 Go to next message
Eclipse UserFriend
Originally posted by: james.ractive.ch

Hello everyone

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 [1], 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
bundles.

Thanks so far,
James


[1]
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 #660769 is a reply to message #660727] Mon, 21 March 2011 14:18 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Very strange situation.

Can you please provide a simplified test case? Set of bundles and we will look it over.

Do your jpa services use interfaces or are they plain classes? How do you specify transactions on those services?

Regards,
Dmitry
Re: Spring transactions with aspectj on Virgo [message #660934 is a reply to message #660769] Tue, 22 March 2011 12:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: james.ractive.ch

Am 21.03.2011 15:18, schrieb Dmitry Sklyut:

Hi Dmitry

Thanks for your reply and your help.

> Very strange situation.
>
> Can you please provide a simplified test case? Set of bundles and we
> will look it over.


I put my modified greenpages app on bitbucket:
https://bitbucket.org/ractive/greenpages-plus

As mentioned previously, this app behaves exactly the same. When
clicking on the newly added "Add Listing" link on the top of the page
and submitting the form, addListing() is called which in turn calls
em.perist(). There is no error or anything, but the entry is just not
created. When using the debugger to step into the code, I can see in
org.eclipse.persistence.internal.jpa.transaction.EntityTrans actionWrapper.checkForTransaction
that entityTransaction is null.

One should be able to import this project into eclipse and run it on a
configured virgo instance inside eclipse.

> Do your jpa services use interfaces or are they plain classes? How do
> you specify transactions on those services?
I changed the greenpages app in a way, there the entity implementation
(JpaListing) is annotated with @Entity and not using orm.xml as the
original app. The transactions are annotated in JpaDirectory.

Just let me know if you need any more information or help.


Best regards,
James
Re: Spring transactions with aspectj on Virgo [message #660938 is a reply to message #660934] Tue, 22 March 2011 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: james.ractive.ch

Am 22.03.2011 13:18, schrieb Jean-Pierre Bergamin:

> One should be able to import this project into eclipse and run it on a
> configured virgo instance inside eclipse.

BTW: As desribed in [1], we had to use spring 3.0.5. The only way to get
it to work, was updating the spring libraries in virgo as well.


Best regards,
James

[1] https://bitbucket.org/ractive/greenpages-plus/changeset/03a1 7f99dca7
Re: Spring transactions with aspectj on Virgo [message #662561 is a reply to message #660769] Thu, 31 March 2011 06:36 Go to previous messageGo to next message
Jean-Pierre Bergamin is currently offline Jean-Pierre BergaminFriend
Messages: 51
Registered: March 2011
Location: Zürich, CH
Member
Am 21.03.2011 15:18, schrieb Dmitry Sklyut:

> Very strange situation.
>
> Can you please provide a simplified test case? Set of bundles and we
> will look it over.
> ...

Could you alrady have a look at this?
Just tell me if we can provide more information about this issue.


Best regards,
James
Re: Spring transactions with aspectj on Virgo [message #662801 is a reply to message #662561] Fri, 01 April 2011 01:49 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Sorry but I did not get time.

Will find time tomorrow to look this over.

Regards,
Dmitry
Re: Spring transactions with aspectj on Virgo [message #663338 is a reply to message #662561] Mon, 04 April 2011 16:56 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Ok. Here is a solution:

Change template.mf for greenpages.jpa to this
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: GreenPages JPA
Bundle-SymbolicName: greenpages.jpa
Bundle-Vendor: SpringSource Inc.
Bundle-Version: 2.3.0
Import-Template: 
 org.springframework.*;version="[3.0.3, 3.1)",
 greenpages;version="[2.3, 2.4)",
 javax.persistence.*;version="[2.0.3, 2.1.0)",
 org.eclipse.persistence.*;version="[2.2.0, 2.3.0)",
 org.apache.commons.dbcp.*;version="[1.2.2.osgi, 1.2.2.osgi]",
 javax.sql;version="0"
Import-Bundle: 
 org.eclipse.persistence.core;version="[2.2.0, 2.3.0)",
 org.eclipse.persistence.jpa;version="[2.2.0, 2.3.0)",
 javax.persistence;version="[2.0.3, 2.1.0)"
Import-Package: 
 org.aspectj.lang;version="0",
 org.aspectj.runtime.reflect;version="0"
Import-Library: 
 org.springframework.spring;version="[3.0.3, 3.1)"
Excluded-Exports: 
 greenpages.jpa
Excluded-Imports: 
 org.springframework.test.*,
 org.junit.*



What changed?

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.

Regards,
Dmitry
Re: Spring transactions with aspectj on Virgo [message #671285 is a reply to message #663338] Tue, 17 May 2011 11:39 Go to previous message
Younes is currently offline YounesFriend
Messages: 1
Registered: May 2011
Junior Member
Hello dears,

I have run in the same issue described by James when I tried to run 'greenpages-2.3.0.RELEASE'. I have applied the solution proposed by Dmitry (changes to template.fm). The application now can persist new instances of 'JpaListing'. However, the application is unstable as it doesn't start always. Very often, I got the exception 'Unable to find the class named [greenpages.jpa.JpaListing]. Ensure the class name/path is correct and available to the classloader.'.

Please, find herein after more details about the case.
1) Version:
* Virgo: 2.1.1.RELEASE
* Springframework: 3.0.0.RELEASE
* JPA: 1.0.0
* EclipseLink: 1.0.0

2) Full application
It is an STS-ready application located at the URL given in the attached file (the Forum doesn't allow me to list directly the link sine this is my first message).

Please let me know in case you need to see the full exception stack. I have omitted pasting it here since it is very huge.

Warm regards

Younes
  • Attachment: url.txt
    (Size: 0.11KB, Downloaded 283 times)
Previous Topic:Error building sample application virgo snap
Next Topic:OSGI bundle dependencies
Goto Forum:
  


Current Time: Thu Dec 26 22:01:51 GMT 2024

Powered by FUDForum. Page generated in 0.04714 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top