users@glassfish.java.net

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

From: Bernhard Thalmayr <bernhard.thalmayr_at_painstakingminds.com>
Date: Wed, 1 Feb 2012 15:14:39 +0100

Hi experts,

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

            Map<String, String> configOverrides = new HashMap<String, String>();
            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

  <persistence-unit name="NAME" transaction-type="RESOURCE_LOCAL">

    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>

    <properties>
      <property name="eclipselink.jdbc.driver"
value="oracle.jdbc.driver.OracleDriver" />
...


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