diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index 4213372c7..be891577c 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -467,7 +467,8 @@ public class PCEnhancer { } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { - throw new GeneralException(e); + throw new GeneralException(_loc.get("enhance-error", + _managedType.getType().getName(), e.getMessage()), e); } } @@ -2736,7 +2737,10 @@ public class PCEnhancer { } catch (Throwable t) { // last-chance catch for bug #283 (which can happen // in a variety of ClassLoading environments) - _log.warn(_loc.get("enhance-uid-access", _meta), t); + if (_log.isTraceEnabled()) + _log.warn(_loc.get("enhance-uid-access", _meta), t); + else + _log.warn(_loc.get("enhance-uid-access", _meta)); } // if we couldn't access the serialVersionUID, we will have to @@ -3672,10 +3676,13 @@ public class PCEnhancer { * attribute name for the backing field name. */ private String fromBackingFieldName(String name) { - if (_meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY + // meta is null when doing persistence-aware enhancement + if (_meta != null + && _meta.getAccessType() == ClassMetaData.ACCESS_PROPERTY && _fieldsToAttrs.containsKey(name)) - name = (String) _fieldsToAttrs.get(name); - return name; + return (String) _fieldsToAttrs.get(name); + else + return name; } /** diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties index 29c140657..39f2e3539 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/enhance/localizer.properties @@ -197,4 +197,5 @@ subclasser-fetch-group-override: The field {1} in type {0} is configured to be \ no-accessor: Could not find method called {0} in type {1}. unspecified-unenhanced-types: One or more of the types in {0} have relations \ to other unenhanced types that were not specified. These unspecified types \ - are: {1} \ No newline at end of file + are: {1} +enhance-error: An error occurred while enhancing {0}. Exception message: {1} \ No newline at end of file