diff --git a/src/main/java/com/avaje/ebeaninternal/server/core/JndiDataSourceLookup.java b/src/main/java/com/avaje/ebeaninternal/server/core/JndiDataSourceLookup.java index 3bd662510..120cce758 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/core/JndiDataSourceLookup.java +++ b/src/main/java/com/avaje/ebeaninternal/server/core/JndiDataSourceLookup.java @@ -11,34 +11,27 @@ import javax.sql.DataSource; */ public class JndiDataSourceLookup { - private static final String DEFAULT_PREFIX = "java:comp/env/jdbc/"; + public JndiDataSourceLookup() { + } - public JndiDataSourceLookup() { - } - - /** - * Return the DataSource by JNDI lookup. - *
- * If name is null the 'default' dataSource is returned. - *
- */ - public DataSource lookup(String jndiName) { + /** + * Return the DataSource by JNDI lookup. + *+ * If name is null the 'default' dataSource is returned. + *
+ */ + public DataSource lookup(String jndiName) { - try { - - if (!jndiName.startsWith("java:")){ - jndiName = DEFAULT_PREFIX + jndiName; - } - - Context ctx = new InitialContext(); - DataSource ds = (DataSource) ctx.lookup(jndiName); - if (ds == null) { - throw new PersistenceException("JNDI DataSource [" + jndiName + "] not found?"); - } - return ds; + try { + Context ctx = new InitialContext(); + DataSource ds = (DataSource) ctx.lookup(jndiName); + if (ds == null) { + throw new PersistenceException("JNDI DataSource [" + jndiName + "] not found?"); + } + return ds; - } catch (NamingException ex) { - throw new PersistenceException(ex); - } - } + } catch (NamingException ex) { + throw new PersistenceException(ex); + } + } }