Commits

Anonymous committed 8bfcee7

Fixed lookup

  • Participants
  • Parent commits 9e6e57a

Comments (0)

Files changed (1)

File src/java/com/opensymphony/user/provider/jdbc/BaseJDBCProvider.java

  * DOCUMENT ME!
  *
  * @author $author$
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public abstract class BaseJDBCProvider implements UserProvider {
     //~ Static fields/initializers /////////////////////////////////////////////
 
         if (jndi != null) {
             try {
-                ds = (DataSource) new InitialContext().lookup(jndi);
-            } catch (NamingException e) {
+                ds = (DataSource) lookup(jndi);
+
+                if (ds == null) {
+                    ds = (DataSource) new javax.naming.InitialContext().lookup(jndi);
+                }
+            } catch (Exception e) {
                 log.fatal("Could not look up DataSource using JNDI location: " + jndi, e);
 
                 return false;
             }
         }
     }
+
+    private Object lookup(String location) throws NamingException {
+        try {
+            InitialContext context = new InitialContext();
+
+            try {
+                return context.lookup(location);
+            } catch (NamingException e) {
+                //ok, couldn't find it, look in env
+                return context.lookup("java:comp/env/" + location);
+            }
+        } catch (NamingException e) {
+            throw e;
+        }
+    }
 }