From 7baaaf4b760248e0e5fdf63903b00f15a4485f78 Mon Sep 17 00:00:00 2001 From: Pinaki Poddar Date: Wed, 27 Sep 2006 23:19:17 +0000 Subject: [PATCH] Fixing http://issues.apache.org/jira/browse/OPENJPA-60 Specifying the wrong persistence implementation in persistence.xml leads to misleading error message git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@450632 13f79535-47bb-0310-9956-ffa450edef68 --- .../persistence/PersistenceProductDerivation.java | 14 ++++++++------ .../openjpa/persistence/localizer.properties | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java index 858c3f371..c73d0a48b 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java @@ -241,15 +241,17 @@ public class PersistenceProductDerivation ConfigurationParser parser = new ConfigurationParser(m); PersistenceUnitInfoImpl pinfo = parseResources(parser, urls, name, loader); - if (pinfo == null || !isOpenJPAPersistenceProvider(pinfo, loader)) { + if (pinfo == null) { if (!explicit) return Boolean.FALSE; - String msg = (pinfo == null) ? "missing-xml-config" - : "cantload-xml-config"; - throw new MissingResourceException(_loc.get(msg, rsrc, - String.valueOf(name)).getMessage(), getClass().getName(), rsrc); + throw new MissingResourceException(_loc.get("missing-xml-config", + rsrc, String.valueOf(name)).getMessage(), getClass().getName(), + rsrc); + } else if (!isOpenJPAPersistenceProvider(pinfo, loader)) { + throw new MissingResourceException(_loc.get("unknown-provider", + rsrc, name, pinfo.getPersistenceProviderClassName()). + getMessage(), getClass().getName(), rsrc); } - cp.addProperties(pinfo.toOpenJPAProperties()); cp.setSource(pinfo.getPersistenceXmlFileUrl().toString()); return Boolean.TRUE; 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 c62b77498..28cbf3a56 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 @@ -60,6 +60,8 @@ missing-xml-config: The specified XML resource "{0}" for persistence unit \ "{1}" can''t be found in your class path. cantload-xml-config: The specified XML resource "{0}" for persistence unit \ "{1}" can''t be parsed. +unknown-provider: Persistence Provider "{2}" specified in persistence unit \ + "{1}" in "{0}" is not a recognized provider. illegal-index: The parameter index {0} is invalid. Parameters must be \ integers starting at 1. conf-load: Setting the following properties from "{0}" into configuration: {1}