Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Classloading issue w/ TempEquinoxEntityLoader(Weaving of entities located in different bundles)
icon9.gif  Classloading issue w/ TempEquinoxEntityLoader [message #494308] Fri, 30 October 2009 08:07 Go to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Hi all,

in my test-scenario my entities are woven if I put them all together into one bundle. But that's not what I want it to be in my existing RCP application. So what needs to be done to make this work? I tried a couple of things but they all failed. Here is what my scenario looks like:

Bundle A contains entity E1, the persistence.xml file and it creates an EMF during the bundle's start-method. Entity E1 is successfully woven. Furthermore I got a bundle B which contains entity E2. Bundle A imports the one and only package of B.

My failed attempts were having Bundle B be an ordinary bundle, be a fragment-bundle of A and also be a fragment-bundle of org.eclipse.persistence.jpa (with the latter one class E2 wasn't even tried to be loaded, with the both first approaches I get a ClassNotFoundException when trying to load class E2).

While debugging I realized that the EquinoxInitializer$TempEquinoxEntityLoader is being asked to load my entities (instead of my handed-in classloader which is saved in the realClassLoader variable). That loader makes a call to findLocalClass which in turn ends up in eclipse.osgi's ClasspathManager being unable to load my class E2.

I really hope someone can help me out with this one. Although I want to use the weaving in my RCP app in the long-run, here I am testing just with a small and simple OSGI runtime configuration.

Thx,
Oliver

Re: Classloading issue w/ TempEquinoxEntityLoader [message #494329 is a reply to message #494308] Fri, 30 October 2009 10:18 Go to previous messageGo to next message
Shaun Smith is currently offline Shaun SmithFriend
Messages: 197
Registered: July 2009
Senior Member
Hi Oliver,

I'll take a look at this but my initial reaction is that all of your Entities need to be in the same bundle so they all are defined in the same classloader--being loadable by the same loader is not sufficient. This should mean that bundle fragments should also work but I can't say I've tried this yet.

As far as RCP is concerned I've had issues with weaving due to the collision of OSGi services and the way RCP apps launch. But I've picked up some tricks at Eclipse Summit Europe I'm going to try out and if they work out I'll update the RCP example to include weaving.

--Shaun

Re: Classloading issue w/ TempEquinoxEntityLoader [message #494339 is a reply to message #494329] Fri, 30 October 2009 10:50 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Hey Shaun,

thanks for investigating on this issue, I'm really curious about your results. I haven't tried building an rcp app where all entities are in the same bundle. But using a simple osgi run configuration and having the entities located in one bundle the weaving is working as expected.

Besides this placing all entity classes into one bundle does not sound like a very modular design approach - what do you think about this?

Thx for your help,
Oliver
Re: Classloading issue w/ TempEquinoxEntityLoader [message #494471 is a reply to message #494329] Fri, 30 October 2009 18:44 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Hi Shaun,

now I am really surprised: I just tried out Milestone M11
(eclipselink-plugins-2.0.0.v20091026-r5655) and the weaving is working
fine. It works for entities coming from fragments *and* also for entites
coming from completely different bundles. I haven't debugged into it to
see what's going on differently comparing to the 1.2.0 version.

Next thing I'm gonna try out is to move on from my osgi run
configuration to my RCP environment... Or I'll verify that lazy-loading
is working as expected first... I will post my results here, maybe it's
helpful for anybody else, too.

-Oliver

Shaun Smith schrieb:
> Hi Oliver,
>
> I'll take a look at this but my initial reaction is that all of your
> Entities need to be in the same bundle so they all are defined in the
> same classloader--being loadable by the same loader is not sufficient.
> This should mean that bundle fragments should also work but I can't say
> I've tried this yet.
>
> As far as RCP is concerned I've had issues with weaving due to the
> collision of OSGi services and the way RCP apps launch. But I've picked
> up some tricks at Eclipse Summit Europe I'm going to try out and if
> they work out I'll update the RCP example to include weaving.
>
> --Shaun
>
>
Re: Classloading issue w/ TempEquinoxEntityLoader [message #494490 is a reply to message #494471] Fri, 30 October 2009 20:31 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
> Next thing I'm gonna try out is to move on from my osgi run
> configuration to my RCP environment...

Shaun, as you already pointed out, getting weaving to work within RCP is
not that easy. The ClassLoadingHook is registered correctly and it opens
its ServiceTracker for IWeaver services without problems. But now I am
stuck getting the EquinoxInitializer loaded. Creating the EMF like this

Persistence.createEntityManagerFactory("foo", properties);

does not cause the mentioned Initializer to be loaded - instead it uses
the OSGIInitializer. So I tried to force using the EquinoxInitializer by
creating the EMF this way:

new
PersistenceProvider(" org.eclipse.persistence.internal.jpa.deployment.osgi.equinox .EquinoxInitializer ").createEntityManagerFactory("foo",properties);

Unfortunately that doesn't work either but results in the following output:

[EL Warning]: 2009-10-30 21:20:09.609--Construction of environment
specific OSGi initializer,
[org.eclipse.persistence.internal.jpa.deployment.osgi.equino x.EquinoxInitializer]
failed with message: [java.lang.ClassNotFoundException:
org.eclipse.persistence.internal.jpa.deployment.osgi.equinox .EquinoxInitializer].
[EL Warning]: 2009-10-30 21:20:09.671--java.lang.ClassNotFoundException:
org.eclipse.persistence.internal.jpa.deployment.osgi.equinox .EquinoxInitializer

Any hints how to move on with this one? :)

Thx,
Oliver
Re: Classloading issue w/ TempEquinoxEntityLoader [message #494500 is a reply to message #494490] Fri, 30 October 2009 21:50 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
> [EL Warning]: 2009-10-30 21:20:09.609--Construction of environment
> specific OSGi initializer,
> [org.eclipse.persistence.internal.jpa.deployment.osgi.equino x.EquinoxInitializer]
> failed with message: [java.lang.ClassNotFoundException:
> org.eclipse.persistence.internal.jpa.deployment.osgi.equinox .EquinoxInitializer].
>
> [EL Warning]: 2009-10-30 21:20:09.671--java.lang.ClassNotFoundException:
> org.eclipse.persistence.internal.jpa.deployment.osgi.equinox .EquinoxInitializer

Please ignore my last posting! For some very very weird reason my RCP
app did not include the org.eclipse.persistence.jpa.equinox fragment.
After adding it, the EquinoxInitializer is being loaded and my entities
are woven. Finally got the weaving working!

-Oliver
Re: Classloading issue w/ TempEquinoxEntityLoader [message #495147 is a reply to message #494500] Tue, 03 November 2009 22:13 Go to previous message
Shaun Smith is currently offline Shaun SmithFriend
Messages: 197
Registered: July 2009
Senior Member
Hi Oliver,

Just to confirm that in pre 2.0 EclipseLink you do need all of your entities in the same bundle as your persistence.xml for weaving to work. However as you have discovered this restriction will be gone in EclipseLink 2.0. This is because we've removed the need for direct access to the classloader of the persistence unit. So with EclipseLink 2.0 you can just create an EntityManagerFactory with the name of the persistence unit and no longer pass a classloader.

I'll be updating the OSGi examples on the wiki for EclipseLink 2.0.

Also, at Eclipse Summit Europe last week I was speaking with Martin Lippert who suggested that the way to enable weaving in an RCP app was to ensure that the org.eclipse.core.runtime bundle is started after the o.e.p.jpa and javax.persistence bundles. The core runtime bundle launches the RCP application and you want to make sure that EclipseLink has setup weaving before the application loads an Entity class. I haven't tried this out yet but thought I'd pass this on to you since you're actively working with RCP.

--Shaun
Previous Topic:Foreign key contraints from optional bundles
Next Topic:Unexpected Behaviour of Teneo while committing a transaction
Goto Forum:
  


Current Time: Tue Mar 19 11:18:07 GMT 2024

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

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

Back to the top