openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Jencks (JIRA)" <>
Subject [jira] Created: (OPENJPA-73) PersistenceProviderImpl.createContainerEntityManagerFactory() doesn't work if you supply jdbc specific properties
Date Tue, 31 Oct 2006 22:19:19 GMT
PersistenceProviderImpl.createContainerEntityManagerFactory() doesn't work if you supply jdbc
specific properties

                 Key: OPENJPA-73
             Project: OpenJPA
          Issue Type: Bug
            Reporter: David Jencks

PersistenceProviderImpl.createContainerEntityManagerFactory() doesn't work if you supply jdbc
specific properties such as 

                        <property name="openjpa.Sequence" value="table(Table=OPENJPASEQ,

(or rather its string equivalent in the map argument)

The problem is that the ClassTransformerImpl creates a OpenJPAConfigurationImpl which doesn't
know anything about jdbc configuration properties such as the sequence, but it gets fed all
the properties you supply.

Changing the code in PersistenceProviderImpl to create a JDBCConfigurationImpl makes everything
work:  heres a patch to do this:

Index: openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
--- openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
      (revision 469568)
+++ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
      (working copy)
@@ -89,17 +89,17 @@
             // add enhancer
             String ctOpts = (String) Configurations.getProperty
                 (CLASS_TRANSFORMER_OPTIONS, pui.getProperties());
-            pui.addTransformer(new ClassTransformerImpl(cp, ctOpts, 
+            pui.addTransformer(new ClassTransformerImpl(cp, ctOpts,
-            BrokerFactory factory = Bootstrap.newBrokerFactory(cp, 
+            BrokerFactory factory = Bootstrap.newBrokerFactory(cp,
             return OpenJPAPersistence.toEntityManagerFactory(factory);
         } catch (Exception e) {
             throw PersistenceExceptions.toPersistenceException(e);
      * Java EE 5 class transformer.
@@ -108,10 +108,24 @@
         private final ClassFileTransformer _trans;
-        private ClassTransformerImpl(ConfigurationProvider cp, String props, 
+        private ClassTransformerImpl(ConfigurationProvider cp, String props,
             final ClassLoader tmpLoader) {
             // create an independent conf for enhancement
-            OpenJPAConfiguration conf = new OpenJPAConfigurationImpl();
+            OpenJPAConfiguration conf = null;
+            try {
+                ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+                Class clazz = Class.forName("org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl",
true, tccl);
+                conf = (OpenJPAConfiguration)clazz.newInstance();
+            } catch (ClassNotFoundException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (InstantiationException e) {
+                e.printStackTrace();
+            }
+            if (conf == null) {
+                conf = new OpenJPAConfigurationImpl();
+            }
             // don't allow connections

It seems to me that using a JDBCConfiguration here is not needed: what is needed is to ignore
properties that the OpenJPAConfigurationImpl doesn't understand, rather than throwing an exception.
 We're only setting up the class transformer here, not the runtime configuration.

I don't understand enough to suggest where to fix this, but given some hints I could make
a try.

The relevant parts of the stacktrace showing the original error is:

Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: table in
classloader org.apache.geronimo.configs/openjpa/1.2-SNAPSHOT/car
        at serp.util.Strings.toClass(
        at serp.util.Strings.toClass(
        at org.apache.openjpa.lib.conf.Configurations.newInstance(
        ... 62 more

        at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(
        at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(
        at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.<init>(
        at org.apache.openjpa.persistence.PersistenceProviderImpl$ClassTransformerImpl.<init>(
        at org.apache.openjpa.persistence.PersistenceProviderImpl.createContainerEntityManagerFactory(
        at org.apache.geronimo.persistence.PersistenceUnitGBean.<init>(

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message