Author: ppoddar
Date: Wed Jun 18 18:41:32 2008
New Revision: 669356
URL: http://svn.apache.org/viewvc?rev=669356&view=rev
Log:
OPENJPA-581: Print WARN level message on JNDI lookup failure
Modified:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
Modified:
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java?rev=669356&r1=669355&r2=669356&view=diff
==============================================================================
---
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
(original)
+++
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
Wed Jun 18 18:41:32 2008
@@ -944,19 +944,21 @@
public Object getConnectionFactory() {
if (connectionFactory.get() == null)
connectionFactory.set(
- lookupConnectionFactory(getConnectionFactoryName()), true);
+ lookupConnectionFactory(getConnectionFactoryName(),
+ connectionFactory.getProperty()), true);
return connectionFactory.get();
}
/**
* Lookup the connection factory at the given name.
*/
- private Object lookupConnectionFactory(String name) {
+ private Object lookupConnectionFactory(String name, String userKey) {
name = StringUtils.trimToNull(name);
if (name == null)
return null;
try {
- return Configurations.lookup(name);
+ return Configurations.lookup(name, userKey,
+ getLog(OpenJPAConfiguration.LOG_RUNTIME));
} catch (Exception ex) {
return null;
}
@@ -1027,7 +1029,8 @@
public Object getConnectionFactory2() {
if (connectionFactory2.get() == null)
connectionFactory2.set(
- lookupConnectionFactory(getConnectionFactory2Name()), false);
+ lookupConnectionFactory(getConnectionFactory2Name(),
+ connectionFactory2.getProperty()), false);
return connectionFactory2.get();
}
Modified:
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java?rev=669356&r1=669355&r2=669356&view=diff
==============================================================================
---
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
(original)
+++
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
Wed Jun 18 18:41:32 2008
@@ -609,14 +609,17 @@
/**
* Looks up the given name in JNDI. If the name is null, null is returned.
*/
- public static Object lookup(String name) {
+ public static Object lookup(String name, String userKey, Log log) {
if (StringUtils.isEmpty(name))
return null;
Context ctx = null;
try {
ctx = new InitialContext();
- return ctx.lookup(name);
+ Object result = ctx.lookup(name);
+ if (result == null && log != null && log.isWarnEnabled())
+ log.warn(_loc.get("jndi-lookup-failed", userKey, name));
+ return result;
} catch (NamingException ne) {
throw new NestableRuntimeException(
_loc.get("naming-err", name).getMessage(), ne);
Modified:
openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties?rev=669356&r1=669355&r2=669356&view=diff
==============================================================================
---
openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
(original)
+++
openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties
Wed Jun 18 18:41:32 2008
@@ -114,3 +114,4 @@
veto-change: Can not modify "{0}" because the property is not dynamic and the \
current configuration is read-only.
+jndi-lookup-failed: JNDI lookup for "{0}" with key "{1}" returned null.
\ No newline at end of file