diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java index 6c362f105..07d43442a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java @@ -37,6 +37,7 @@ import org.apache.openjpa.kernel.Bootstrap; import org.apache.openjpa.kernel.BrokerFactory; import org.apache.openjpa.lib.conf.ConfigurationProvider; import org.apache.openjpa.lib.conf.Configurations; +import org.apache.openjpa.lib.util.Localizer; import org.apache.openjpa.meta.MetaDataModes; import org.apache.openjpa.meta.MetaDataRepository; import org.apache.openjpa.util.ClassResolver; @@ -53,6 +54,9 @@ public class PersistenceProviderImpl static final String CLASS_TRANSFORMER_OPTIONS = "ClassTransformerOptions"; + private static final Localizer _loc = Localizer.forPackage( + PersistenceProviderImpl.class); + /** * Loads the entity manager specified by name, applying * the properties in m as overrides to the properties defined @@ -91,10 +95,16 @@ public class PersistenceProviderImpl return null; // add enhancer + Exception transformerException = null; String ctOpts = (String) Configurations.getProperty (CLASS_TRANSFORMER_OPTIONS, pui.getProperties()); - pui.addTransformer(new ClassTransformerImpl(cp, ctOpts, - pui.getNewTempClassLoader())); + try { + pui.addTransformer(new ClassTransformerImpl(cp, ctOpts, + pui.getNewTempClassLoader())); + } catch (Exception e) { + // fail gracefully + transformerException = e; + } // if the BrokerImpl hasn't been specified, switch to the // non-finalizing one, since anything claiming to be a container @@ -107,6 +117,11 @@ public class PersistenceProviderImpl BrokerFactory factory = Bootstrap.newBrokerFactory(cp, pui.getClassLoader()); + if (transformerException != null) + factory.getConfiguration().getLog( + OpenJPAConfiguration.LOG_RUNTIME).warn( + _loc.get("transformer-registration-error", pui), + transformerException); return OpenJPAPersistence.toEntityManagerFactory(factory); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); diff --git a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties index 78a22f9b6..4857778d3 100644 --- a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties +++ b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties @@ -125,6 +125,9 @@ no-setter-for-getter: No setter was found for method {0} in type {1} while \ searching for persistent properties. This method will be ignored. If you \ intended for this to be persistent, please add a corresponding setter, \ or switch to field access for this type hierarchy. +transformer-registration-error: An error occurred while registering a \ + ClassTransformer with {0}. The error is logged along with this warning. \ + Load-time class transformation will not be available. EntityManagerFactory-name: EntityManagerFactory implementation EntityManagerFactory-desc: Allows extension of standard \