I have created two datasource in weblogic with below jndi names
I am able to access datasource testDatasource1 using java but while access dataource jdbc/testDatasource i am getting below mention error
javax.naming.NameNotFoundException: While trying to lookup 'jdbc.testDatasource' didn't find subcontext 'jdbc'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'jdbc.testDatasource' didn't find subcontext 'jdbc'. Resolved '']; remaining name 'jdbc/testDatasource'
it seem that prefix jdbc/ is giving problem.
May sound stupid, but since it happened to me I'll share it.
When you create the datasource under Weblogic (at least 10.3.4), don't forget to go through the whole configuration process (The Finish
button is enabled before the end).
On this very last page, you'll be able to activate
the datasource for a server, not only create it.
To check if your DB is up you can look the JNDI tree of the server.
In some cases, it is caused by the datasource not in the same target with your servers. The servers that are using the datasource should be added to the same targets.
I've faced the same problem. My application is connecting to a Oracle DB that runs on a local Oracle Sql Server (Oracle XE 11g). From other answers I've seen that deleting the Weblogic cache /tmp, /cache and even /logs might work. My problem was that the local service Oracle Service XE was STOPPED. I know it's silly but it might help. So you should do this 3 things:
- clear cache;
- check if the DB server service is running;
- try restarting the WEBLOGIC server;
Those things above worked for me.
java is the root JNDI namespace for resources.
So maybe you need
dataSource = (javax.sql.DataSource) context.lookup("java:jdbc/testDatasource");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With