Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Virgo + EclipseLink JPA + Weaving + Spring
Virgo + EclipseLink JPA + Weaving + Spring [message #709491] Thu, 04 August 2011 00:30 Go to next message
Eric Hough is currently offline Eric HoughFriend
Messages: 14
Registered: July 2010
Junior Member
Hi,

I'm trying to get a handle on the current best practice for integrating the four technologies outlined in the title. Currently using Virgo 3.0.0.RC1 and EclipseLink 2.3.0.

With EclipseLink weaving disabled entirely, all the pieces fit together and work with no effort. I can using Spring to create an EntityManagerFactory and export the service over OSGi for consumption by clients (neat!).

But what I really want to do is use EclipseLink weaving for lazy loading of entity associations. After spending nearly a full week working on it, I finally managed to get weaving working using the technique in [1], which is based on Martin Lippert's work [2]. I'm not jazzed about the idea of adding a framework hook, and it seems that Equinox Aspects hasn't really been updated in two years. Is Equinox Aspects dead?

So my question is, is [1] really the only way to get EclipseLink weaving to work with Virgo? EclipseLink offers some instructions at [3] and [4], but they don't seem to be relevant when using both Virgo AND Spring.

Any pointers would be appreciated. I'm happy to provide a working sample of my setup if anyone is interested in working on it.

[1] http://angelozerr.wordpress.com/2010/04/30/springweaver_step1/
[2] http://martinlippert.blogspot.com/2009/04/load-time-weaving-for-spring-dm.html
[3] http://wiki.eclipse.org/EclipseLink/Examples/OSGi/Equinox_Byte_Code_Weaving
[4] http://wiki.eclipse.org/EclipseLink/Examples/JPA/JPASpring
Re: Virgo + EclipseLink JPA + Weaving + Spring [message #709912 is a reply to message #709491] Thu, 04 August 2011 13:25 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Eric,

Can you please provide your test set-up. I will take a stab at it.

Regards,
Dmitry
Re: Virgo + EclipseLink JPA + Weaving + Spring [message #710237 is a reply to message #709912] Thu, 04 August 2011 20:59 Go to previous messageGo to next message
Eric Hough is currently offline Eric HoughFriend
Messages: 14
Registered: July 2010
Junior Member
Thanks, Dmitry! Here are two packages you can use to test:

There is a README.txt inside each to explain how to test with these. They're essentially just overlays that you can copy on top of Virgo Kernel 3.0.0.RC2. I recommend starting with the non-lazy-eclipselink.tgz and a fresh copy of Virgo Kernel, then try the lazy-eclipselink.tgz with a separate fresh copy of Virgo Kernel.

Please let me know if you have any questions or trouble getting the samples to run. Thanks!
Re: Virgo + EclipseLink JPA + Weaving + Spring [message #713978 is a reply to message #710237] Tue, 09 August 2011 14:05 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Hi Eric,

I only got it to work without FrameworkHook by using scoped deployment, i.e. par or a scoped plan. If this is not your goal - than FrameworkHook is the only other alternative that I can think off.

Here is what I did to get eclipse link to LTW domain classes.

1. Add <context:load-time-weaver /> to eclipselink/META-INF/spring/ejb.xml to enable LTW. Enabled LTW in persistence.xml

Result:

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_set_customer_vh] or [_persistence_get_customer_vh] is not defined in the object [org.example.domain.Order].
Internal Exception: java.lang.NoSuchMethodException: org.example.domain.Order._persistence_get_customer_vh()
Mapping: org.eclipse.persistence.mappings.ManyToOneMapping[customer]
Descriptor: RelationalDescriptor(org.example.domain.Order --> [DatabaseTable(orders)])

Exception [EclipseLink-218] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException would have occurred accessing a non-existent weaved _vh_ method [_persistence_get_customer_vh].  The class was not weaved properly - for EE deployments, check the module order in the application.xml deployment descriptor and verify that the module containing the persistence unit is ahead of any other module that uses it.



2. Created a scoped plan including changes in #1 (excluding domain bundle as it should be resolved by imports)
<plan name="org.example.forum" version="1.0.0" scoped="true" atomic="true"
                xmlns="http://www.eclipse.org/virgo/schema/plan"
				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
				xsi:schemaLocation="
					http://www.eclipse.org/virgo/schema/plan 
					http://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd">
					
			        <artifact type="bundle" name="org.example.eclipselink-nolazy"/>
			        <artifact type="bundle" name="org.example.client"/>
</plan>


Result:

Same as #1

2. Added in org.example.domain to the scoped plan.

Result:
Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.internal.weaving.PersistenceWeaved
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:134)
	... 47 common frames omitted
	

3. Add Import-Bundle for org.eclipse.persistence.core;import-scope:=application and org.eclipse.persistence.jpa;import-scope:=application to the org.example.eclipselink-nolazy bundle

Result:

Classes are weaved and log output is attached.

[2011-08-09 09:57:52.377] DEBUG region-dm-5                  org.example.client.Client                                         Client invoked 
[2011-08-09 09:57:52.377] DEBUG region-dm-5                  org.example.client.Client                                         Customer is a weaved class 
[2011-08-09 09:57:52.377] DEBUG region-dm-5                  org.example.client.Client                                         Looking up all orders 
[2011-08-09 09:57:52.385] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        client_acquired 
[2011-08-09 09:57:52.386] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        acquire_unit_of_work_with_argument 
[2011-08-09 09:57:52.407] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        begin_unit_of_work_flush 
[2011-08-09 09:57:52.407] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        end_unit_of_work_flush 
[2011-08-09 09:57:52.407] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        execute_query 
[2011-08-09 09:57:52.408] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        acquire_connection 
[2011-08-09 09:57:52.408] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        reconnecting_to_external_connection_pool 
[2011-08-09 09:57:52.409] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        SELECT ID, CUSTOMER_ID FROM orders 
[2011-08-09 09:57:52.414] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        release_connection 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        begin_unit_of_work_commit 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        end_unit_of_work_commit 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        resume_unit_of_work 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        release_unit_of_work 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        client_released 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.client.Client                                         Done looking up orders 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        execute_query 
[2011-08-09 09:57:52.415] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        execute_query 
[2011-08-09 09:57:52.416] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        acquire_connection 
[2011-08-09 09:57:52.416] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        reconnecting_to_external_connection_pool 
[2011-08-09 09:57:52.416] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        SELECT ID, PRODUCTNAME, CUSTOMER_ID FROM orders WHERE (ID = ?)
	bind => [1] 
[2011-08-09 09:57:52.417] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        release_connection 
[2011-08-09 09:57:52.417] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        execute_query 
[2011-08-09 09:57:52.417] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        acquire_connection 
[2011-08-09 09:57:52.417] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        reconnecting_to_external_connection_pool 
[2011-08-09 09:57:52.418] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        SELECT ID FROM CUSTOMER WHERE (ID = ?)
	bind => [1] 
[2011-08-09 09:57:52.419] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        release_connection 
[2011-08-09 09:57:52.419] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        execute_query 
[2011-08-09 09:57:52.419] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        acquire_connection 
[2011-08-09 09:57:52.419] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        reconnecting_to_external_connection_pool 
[2011-08-09 09:57:52.420] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        SELECT ID, NAME FROM CUSTOMER WHERE (ID = ?)
	bind => [1] 
[2011-08-09 09:57:52.420] DEBUG region-dm-5                  org.example.eclipselink.Slf4jSessionLogger                        release_connection 
[2011-08-09 09:57:52.421] DEBUG region-dm-5                  org.example.client.Client                                         Fancy Product was purchased by Eric Hough 


Regards,
Dmitry
  • Attachment: forum.tgz
    (Size: 4.88KB, Downloaded 245 times)
Re: Virgo + EclipseLink JPA + Weaving + Spring [message #716255 is a reply to message #713978] Tue, 16 August 2011 19:43 Go to previous message
Eric Hough is currently offline Eric HoughFriend
Messages: 14
Registered: July 2010
Junior Member
Thank you, Dmitry!

I apologize that I didn't respond earlier - just saw your response today. In my case a scoped deployment doesn't fit my requirements. But framework hooks seem to be working fine for me, and hopefully this thread can help out some other poor soul trying to configure EclipseLink weaving inside OSGi Smile

Thanks again for the outstanding support - I really appreciate it!
Previous Topic:Set up a local directory as a repository
Next Topic:Remote Repository Timing and Dependency Issues
Goto Forum:
  


Current Time: Sat Apr 20 00:41:20 GMT 2024

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

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

Back to the top