Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsEclipseLink persistance.xml Tomcat OSGI
https://www.eclipse.org/forums/index.php/mv/msg/156849/494427/#msg_494427
I am working on project which uses EclipseLink and OSGi on Tomcat server. If I put persistence.xml in EclipseLink bundle (META-INF\persistence.xml) and deploy it in tomcat with bridge.war, it works very fine.
But I want to take out persistence.xml out of bundle jar and put that somewhere in Tomcat environment so that DB can be configured without changing the bundle jar.
My question is: Can I put META-INF\persistence.xml in tomcat environment where EclipseLink bundle is in bridge\WEB-INF\eclipse\plugin? If yes, please suggest me, where should I put it.
Thank you very much in advance.
Ashish ]]>Ashish 2009-10-30T15:16:44-00:00Re: EclipseLink persistance.xml Tomcat OSGI
https://www.eclipse.org/forums/index.php/mv/msg/156849/494828/#msg_494828
I don't have any direct experience with your configuration but typically when deploying in a fully Java EE app server a datasource is used to decouple the persistence unit from the actual database. This is similar to your situation and may be the way to go.
Unfortunately, the OSGi Alliance specifications for JDBC and JNDI have not yet been finalized so until that is available you'll need some custom code.
I've blogged about how to pass a datasource to EclipseLink. So you can definitely remove the connection details from the persistence.xml but you have to find a way to instantiate the datasource and pass it into your EntityManagerFactory creation. I'm not sure where in Tomcat you could place the connection information and further you'd need to introduce an import-package for the driver itself. You could work around the import-package by obtaining the driver from a service (which is what the OSGi JDBC spec is going to do) or through some sort of wrapper bundle that decouples you from the actual driver class.
I think I raise more questions than I answer , but hopefully some of the ideas I'm throwing out will get you started. The key question for you is even if you can extract the database connection information from the persistence.xml, how will EclipseLink or your code have visibility of the required JDBC driver?
--Shaun]]>Shaun Smith2009-11-02T20:03:42-00:00Re: EclipseLink persistance.xml Tomcat OSGI
https://www.eclipse.org/forums/index.php/mv/msg/156849/496619/#msg_496619
maybe it is a solution for you you not to use the persistence.xml at
all, as it can be overriden by the use of properties when creating the
emf. This would enable you to retreive the properties form outside the
bundle and put them into the emf. That way you could provide the
settings in a file outside the bundle jar. Im thinking of something like
this:
// retrive the the properties-file from somwhere and load it
.....
// hand it over to the emf, which will override the settings in the
persistence.xml
Ashish schrieb:
> Hello,
> I am working on project which uses EclipseLink and OSGi on Tomcat
> server. If I put persistence.xml in EclipseLink bundle
> (META-INF\persistence.xml) and deploy it in tomcat with bridge.war, it
> works very fine.
>
> But I want to take out persistence.xml out of bundle jar and put that
> somewhere in Tomcat environment so that DB can be configured without
> changing the bundle jar.
>
> My question is: Can I put META-INF\persistence.xml in tomcat environment
> where EclipseLink bundle is in bridge\WEB-INF\eclipse\plugin? If yes,
> please suggest me, where should I put it.
>
> Thank you very much in advance.
>
> Ashish]]>Thomas Haskes2009-11-10T16:59:20-00:00