Skip to main content

GF 3.1.1 JPA ... Persistence.createEntityManagerFactory vs. persistence.xml --- migration issue

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
Bernhard Thalma...
Offline
Joined: 2011-10-10

Hi experts,

I do have some application which uses JavaSE code to create the
EntityManagerFachtory

Map configOverrides = new HashMap();
configOverrides.put("toplink.jdbc.url",
properties.getDatabaseUrl());
configOverrides.put("toplink.jdbc.user",
properties.getDatabaseUser());
configOverrides.put("toplink.jdbc.password",
properties.getDatabasePasswort());
entityManagerFactory =
Persistence.createEntityManagerFactory("NAME",configOverrides);

within persistence.xml toplink is configured.

According to the upgrade-guide I do have to change 'toplink' provider
to 'eclipse-link' provider.

Although I've chanaged all properties within persistence.xml from
'toplink' to 'eclipselink' it seems that with GF 3.1.1 these
properties are not taken into account when an EntitiyManagerFactory is
created with Java SE code.

With GF 2.1.1 the properties from persistence.xml and the one set
programmatically have been accumulated.

With GF 3.1.1 I get the following exception

[#|2012-02-01T14:35:58.815+0100|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=102;_ThreadName=Thread-2;|[EL
Severe]: 2012-02-01 14:35:58.814--ServerSession(32630911)--Local
Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found
for jdbc:oracle:thin:......

However persitence.xml has set

org.eclipse.persistence.jpa.PersistenceProvider
false

...

Is this the expected behaviour or should I consider this as a bug?

TIA,
Bernhard

--
IT-Consulting Bernhard Thalmayr
- Painstaking Minds -
83620 Vagen (Munich area)
Germany

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
al130959
Offline
Joined: 2005-09-28

Hi Bernhard,

Am 01.02.2012 15:14, schrieb Bernhard Thalmayr:
> [#|2012-02-01T14:35:58.815+0100|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=102;_ThreadName=Thread-2;|[EL
> Severe]: 2012-02-01 14:35:58.814--ServerSession(32630911)--Local
> Exception Stack:
> Exception [EclipseLink-4002] (Eclipse Persistence Services -
> 2.3.0.v20110604-r9504):
> org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception: java.sql.SQLException: No suitable driver found
> for jdbc:oracle:thin:......
>
> However persitence.xml has set
>
>
>
> org.eclipse.persistence.jpa.PersistenceProvider
> false
>
>
> value="oracle.jdbc.driver.OracleDriver" />
> ...
from the exception text that you receive, I'd assume that something
different is going on and GF is not properly finding your
persistence.xml and taking it into account: The exception complains
about the drivers class name, not the URL.

I'd start by (just temporarily) providing all information including DB
url, user and password in your persistence.xml and see whether it works
then - and I suspect it won't work with your current setup, but for
another underlying reason which you need to identify...

HTH & best regards,

Andreas

--
Andreas Loew | Senior Java Architect
Oracle Advanced Customer Services
ORACLE Germany