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
This commit is contained in:
Pinaki Poddar 2006-09-27 23:19:17 +00:00
parent 3620b80ce4
commit 7baaaf4b76
2 changed files with 10 additions and 6 deletions

View File

@ -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;

View File

@ -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}