I have the below code for a normal JSP and Java application in JDeveloper 12c
public String getDSName() {
String dsn = null;
try{
// Context env = (Context)new InitialContext().lookup("java:comp/env");
// dsn = (String)env.lookup("jdbc.name");
dsn = "/jdbc/myDS";
}
When I execute the JSP to run in browser, it throws the below error.
javax.naming.NameNotFoundException: Unable to resolve 'jdbc.myDS'. Resolved 'jdbc'; remaining name 'myDS'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1292)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:354)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:227)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:214)
at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228)
at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532)
at weblogic.jndi.internal.RootNamingNode.lookup(RootNamingNode.java:84)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:228)
at weblogic.jndi.internal.ServerNamingNode.lookup(ServerNamingNode.java:532)
at weblogic.jndi.internal.RootNamingNode.lookup(RootNamingNode.java:84)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:307)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:435)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
This is not in the server where JNDI/JDBC to be assigned to a Adminserver; I am running from JDeveloper where connection is created under connections node.