Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EntityManager can't find entities with URLClassLoader(EntityManager can't find entities with URLClassLoader)
EntityManager can't find entities with URLClassLoader [message #664415] Fri, 08 April 2011 17:56 Go to next message
John Borland is currently offline John Borland
Messages: 1
Registered: April 2011
Junior Member
I have a rather unusual situation, my apologies if this has been covered elsewhere. I was unable to find anyone with the same problem.

I am using EclipseLink in the context of LiveConnect, which allows Firefox extensions to run Java code. This involves creating a URLClassLoader to load jars into LiveConnect.

I am able to create an EntityManager, but it can't see any of the entities. In other words, when I call EntityManagerFactory.getMetamodel().getEntities(), it is empty. When I run the same code with the same database, persistence.xml, etc, outside of the firefox context, the entities are all there. I have all of the entities explicitly listed in persistence.xml in both situations.

My hunch is that this has something to do with the URLClassLoader, but I am kind of stumped beyond that. The URLClassLoader I am using has no problem loading the entity classes. I tried specifying entity mappings in orm.xml instead, but then EclipseLink complains about not being able to find the class.

Is there a way to add entities directly to the EntityManager with an existing class object? I was not able to find one. I am looking for some mechanism where I can say to the EntityManager, "here is the entity that you seek!" but I have not found a way to do so.

I am using:
Eclipse Helios Service Release 2, Build id: 20110301-1815
EclipseLink 2.1.x (as it is shown in eclipse, this includes:
javax.persistence_2.0.1.v201006031150.jar
org.eclipse.persistence.core_2.1.2.v2010206-r8635.jar
org.eclipse.persistence.jpa_2.1.2.v2010206-r8635.jar
org.eclipse.persistence.asm_2.1.2.v2010206-r8635.jar
org.eclipse.persistence.antlr_2.1.2.v2010206-r8635.jar)
derby 10.6.1.0
firefox 4.0
java 1.6.0_24

Thanks for any advice... I can put together a minimal demo app that shows the problem if anyone is intrigued but has no immediate suggestions.
Re: EntityManager can't find entities with URLClassLoader [message #664726 is a reply to message #664415] Mon, 11 April 2011 17:40 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

There is a "eclipselink.classloader" persistence unit property that may work. Try setting this to be the URL loader when you are creating your EntityManagerFactory.


James : Wiki : Book : Blog : Twitter
Previous Topic:NullPointerException in DescriptorEventManager.notifyListener
Next Topic:java.lang.NoSuchFieldError: _persistence_listener
Goto Forum:
  


Current Time: Fri Oct 24 21:25:32 GMT 2014

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

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