Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access weblogic datasource from java with prefix jdbc/

I have created two datasource in weblogic with below jndi names

  • jdbc/testDatasource
  • testDatasource1

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.

like image 925
raoul.nair Avatar asked Sep 05 '13 23:09

raoul.nair


4 Answers

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.

like image 65
Michael Laffargue Avatar answered Nov 12 '22 10:11

Michael Laffargue


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.

like image 34
bvhoang Avatar answered Nov 12 '22 09:11

bvhoang


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.

like image 3
bogdan.rusu Avatar answered Nov 12 '22 11:11

bogdan.rusu


java is the root JNDI namespace for resources.

So maybe you need

dataSource = (javax.sql.DataSource) context.lookup("java:jdbc/testDatasource");
like image 1
Scary Wombat Avatar answered Nov 12 '22 11:11

Scary Wombat