This content has been marked as final. Show 4 replies
Please change the below line of code from
DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/mydb");
DataSource ds = (DataSource)initContext.lookup("java:comp/env/jdbc/mydb");
Let us know if the issue still persists...
Thanks a lot Vijaya for replying.
I tried your suggesting but still I am getting below error:
Cannot establish DB connection to JNDI:java:comp/env/jdbc/mydb While trying to look up comp/env/jdbc/mydb in /app/webapp/sample.war/92552029. caused by: javax.naming.NameNotFoundException: While trying to look up comp/env/jdbc/mydb in /app/webapp/sample.war/92552029.; remaining name 'comp/env/jdbc/mydb'
As per error message it says that it is trying to get the JNDI object from my sample web application:
javax.naming.NameNotFoundException: While trying to look up comp/env/jdbc/mydb in /app/webapp/sample.war/92552029.
But I have created it in my weblogic console, how can I map that to my web-application sample.war, is there any additional step that I am missing to configure the JNDI object?
Well.. you can check the JNDI Tree in the weblogic Server Admin console -Servers Section to see if the mydb object is binded to the tree.
If it is not binded to the tree, it is obvious that you end up with NameNotFoundException thrown by the JNDI subsystem.
You will also need to ensure that the mydb datasource is created in the weblogic server successfully.
Please the datasource configuration file that exists under domain_home\config\jdbc directory.
Hope this helps!!
I believe you can simply use "jdbc/mydb" to lookup the datasource. Or if you want to use the compatible naming, you need to specify resource mapping in web.xml.
Rock (Oracle ACS)