Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] PersistenceProvider.createContainerEntityManagerFactory in OSGi Environment

Hi Philipp,

When createContainerEntityManagerFactory() is used some assumptions will be made about the environment that it is invoked in - based on what the JPA spec allows. For instance:

- PersistenceUnitInfo will be already be properly constructed - rather than constructed by the provider - persistenceUnitInfo.getNewTempClassLoader() will provide a classloader that conforms with the spec rules for that classloader - the environment will be setup so that all classes can be discovered by the provider (some guarantees can be made about the default behavior of exclude-unlisted-classes)

Basically we assume we are specifically in a Java EE container. How have you built your PersistenceUnitInfo? Does Spring's JPA integration help deal with this in OSGi?

Given that we are not aware of a Java EE Container that provides the hooks we need in an OSGi way, we have not done any of the investigation necessary to bring this to a usable level. Given that a number of application servers are moving towards OSGi, it is certainly something we will want to investigate.

You should be able to use the javax.persistence.jtaDataSource and javax.persistence.nonJtaDataSource properties in the map provided to createEntityManagerFactory(String, Map) method to pass in the datasources.

-Tom

Philipp Nanz wrote:
Hi folks,

I am currently investigating venues to setup JPA w/ EclipseLink in a
100% OSGi project on top of Spring DM.

Now what puzzles me is that PersistenceProvider.createContainerEntityManagerFactory is
explicitly disabled in the OSGi environment.

This is problematic because it is effectively the only way to inject a
datasource into the mix without JNDI.

Is there a specific reason for this? Because I have subclassed the
non-OSGi PersistenceProvider analogous to the OSGi one, but kept that
method intact -- and it seems to work fine.

Also from reading the JPA 1.0 spec (EJB 3.0 Persistence) I could not
discover any conflict of this method with the OSGi environment in general.

It would be great if anyone could clear this up!

Kind regards,
Philipp

PS: This issue is also discussed in Bug #252263
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


Back to the top