diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/util/WrappedException.java b/openjpa-kernel/src/main/java/org/apache/openjpa/util/WrappedException.java index d486d3dcc..147469b24 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/util/WrappedException.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/util/WrappedException.java @@ -18,20 +18,36 @@ */ package org.apache.openjpa.util; +import org.apache.openjpa.lib.util.Localizer.Message; + @SuppressWarnings("serial") /** * Identifiable exception type which wraps an internal runtime exception. */ public class WrappedException extends OpenJPAException { - - private RuntimeException _wrappedException = null; - public WrappedException(RuntimeException e) { - _wrappedException = e; + /* + * Methods extending OpenJPAException + * See StoreException for similar behavior + */ + public WrappedException(String msg) { + super(msg); } - - public RuntimeException getWrapped() { - return _wrappedException; + + public WrappedException(Message msg) { + super(msg.getMessage()); + } + + public WrappedException(Throwable cause) { + super(cause); + } + + public WrappedException(String msg, Throwable cause) { + super(msg, cause); + } + + public WrappedException(Message msg, Throwable cause) { + super(msg.getMessage(), cause); } @Override diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/validation/ValidationException.java b/openjpa-kernel/src/main/java/org/apache/openjpa/validation/ValidationException.java index 53a38ceb4..43e001188 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/validation/ValidationException.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/validation/ValidationException.java @@ -26,4 +26,9 @@ public class ValidationException extends WrappedException { public ValidationException(RuntimeException e) { super(e); } + + public ValidationException(RuntimeException e, boolean fatal) { + super(e); + setFatal(fatal); + } } diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java index 4d888f569..177a5b98e 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidationUtils.java @@ -79,7 +79,8 @@ public class ValidationUtils { // fatal error - ValidationMode requires a validator log.error(_loc.get("vlem-creation-error"), e); // rethrow as a WrappedException - throw new ValidationException(new RuntimeException(e)); + throw new ValidationException( + new RuntimeException(e), true); } else { // no optional validation provider, so just trace output if (log.isTraceEnabled()) { @@ -106,7 +107,7 @@ public class ValidationUtils { // fatal error - ValidationMode requires a validator log.error(_loc.get("vlem-creation-error"), e); // rethrow as a WrappedException - throw new ValidationException(e); + throw new ValidationException(e, true); } else { // unexpected, but validation is optional, // so just log it as a warning 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 26e5cf2c7..da2dc56d4 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 @@ -196,9 +196,5 @@ invalid-orderBy: This is not a valid OrderBy annotation. The property or \ dynamic-agent: OpenJPA dynamically loaded the class enhancer. Any classes \ that were not enhanced at build time will be enhanced when they are \ loaded by the JVM. -vlem-creation-warn: Could not create the optional validation provider. \ - Reason returned: "{0}" -vlem-creation-error: A fatal error occurred while trying to \ - create the required validation provider. vlem-creation-info: OpenJPA dynamically loaded a validation provider. diff --git a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/validation/localizer.properties b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/validation/localizer.properties new file mode 100644 index 000000000..f41fff8c3 --- /dev/null +++ b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/validation/localizer.properties @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +vlem-creation-warn: Could not create the optional validation provider. \ + Reason returned: "{0}" +vlem-creation-error: A fatal error occurred while trying to \ + create the required validation provider. +