Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Force specify persistence provider for generate tables(Problems generating tables from entities due to incorrect persistence provider)
Force specify persistence provider for generate tables [message #659312] Sat, 12 March 2011 04:19 Go to next message
Jeff Metcalf is currently offline Jeff Metcalf
Messages: 2
Registered: March 2011
Junior Member
Hi,

I am currently having problems calling the Dali generate tables from entities function. Since I understand that the tool ignores the provider setting in the persistence.xml, I am looking for any way to force the tool to use a specified provider so that the correct EntityManagerFactory gets created.

To help provide better clarity on the problem, I will describe my scenario in more detail.

I have correctly set up a JPA facet for my Eclipse project to use EclipseLink 1.1.x. If I keep the project classpath simple and self contained, everything works fine. However I need to add an additional project to my classpath that exports an Oracle Weblogic 11g runtme. After adding the rutime to the classpath, the generate tables fails since OpenJPA is somehow taking precedence as the provider. I understand OpenJPA is the default provider on this version of the Weblogic runtime, but I have no idea how it is managing to override my EclipseLink setting. I assume some configuration file in the runtime classpath somewhere is defining OpenJPA as the default provider and effectively shadowing EclipseLink. I have tried forcing the runtime libraries to the end of the classpath (after EclipseLink jars), but this does not help.

If anyone knows how the OpenJPA provider is managing to take precedence over EclipseLink AND can help me find a way to force specify my preferred provider to the Dali WTP tools, especially for generate tables from entities, that would be most excellent.

Best regards,

J. Metcalf
Re: Force specify persistence provider for generate tables [message #659554 is a reply to message #659312] Mon, 14 March 2011 15:12 Go to previous messageGo to next message
Neil Hauge is currently offline Neil Hauge
Messages: 469
Registered: July 2009
Senior Member
Hi Jeff,

What is the exact version of 11g that your are using (10.x.x)?

Neil
Re: Force specify persistence provider for generate tables [message #659626 is a reply to message #659554] Mon, 14 March 2011 20:34 Go to previous messageGo to next message
Jeff Metcalf is currently offline Jeff Metcalf
Messages: 2
Registered: March 2011
Junior Member
Hi Neil,

Thanks for your reply. The version is Oracle Weblogic 11gR1 runtime environment (10.3.2.0) . However I believe that I have solved the issue by using the information posted here:

http://seamframework.org/96952.lace

The key information was found in the final response currently at the bottom. I will include the critical point here:

Quote:
I have just solved the problem, so want to share the solution. In Weblogic 10.3 Persistence class stores PersistenceProvider instances in a protected static final Set. It gets filled up at startup time with default providers accessible from CLASSPATH (openjpa and kodo in my case). After startup no PersistenceProvider is added to the Set any more, while filling up is implemented by lazy init. As Set is no longer empty, searching forPersistenceProvider instances is skipped.


Basically you need to verify in your classpath that the javax.persistence.Persistence loaded by the generate tables tool ClassLoader is the Eclipse version and NOT the Weblogic version. The Weblogic Persistence class uses a different algorithm to load and cache the available persistence providers which somehow prevented the proper EclipseLink provider from loading.

I don't have any more time to dig further to understand why the EclipseLink provider is not loading with Weblogic's Persistence class, but I suspect that the problem stems from the fact that my Eclipse project is using the Dali plugin defined EclipseLink version 1.1.x, and the Weblogic modules have EclipseLink 1.2.0 in the classpath. The incompatibilities between the two versions may be causing the EclipseLink version 1.1.x provider from the plugin to report as uneligible for my Persistence Unit in the Weblogic Persistence class bootstrapper.

Re: Force specify persistence provider for generate tables [message #659882 is a reply to message #659312] Tue, 15 March 2011 21:28 Go to previous message
Neil Hauge is currently offline Neil Hauge
Messages: 469
Registered: July 2009
Senior Member
Jeff,

I was looking at the following thread on the Oracle forums to see what might be a good workaround. Maybe this will be helpful - http://forums.oracle.com/forums/thread.jspa?threadID=1017020 &tstart=0.

On the Dali side, we should be calling the EclipseLink provider directly to create the EntityManagerFactory when the EclipseLink platform is being used. This would eliminate issues like this where there are multiple providers available. I'd like to make this change for the upcoming Dali 3.0 (Indigo) release, which will be useful for preventing this in the future.

Let me know if you need further assistance with a workaround.

Neil

Previous Topic:orphanRemoval=true
Next Topic:[SOLVED] Limited number of tables
Goto Forum:
  


Current Time: Sun Sep 21 00:10:36 GMT 2014

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

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