on 11-23-2005 10:05 AM
Hi,
I know the issue has been risen a couple of times here, but I was not able to find the solution for me. I cannot retrieve my datasource for my server component. I am a not to sure about some configuration details:
<b>1. Visual Admistrator - JDBC Connector configuration</b>
How does the application name affect the lookup operation of the DS in JNDI. Or is it simply a name to group datasources?
<b>2. Configuration of the DataSource</b>
I have a DS with the name direct_jdbc and an alias myApp/jdbc/datasources/direct_jdbc. I can see the datasource in the JNDI Registry at multiply nodes.
+ root/jdbc/direct_jdbc
+ root/jdbc/myApp/jdbc/datasources/direct_jdbc
+ root/jdbc/notx/direct_jdbc
+ root/jdbc/notx/myApp/jdbc/datasources/direct_jdbc
+ root/jdbc/client/jdbc/direct_jdbc
+ root/jdbc/client/jdbc/myApp/jdbc/datasources/direct_jdbc
Why are the "notx" and "client" nodes containing DS references? Which one do I need to lookup?
I have defined the following <db-properties> in my persistent.xml files:
<db-properties>
<data-source-name>
myApp/jdbc/datasources/direct_jdbc
</data-source-name>
</db-properties>
My client lookup is as follows:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/myApp/jdbc/datasources/direct_jdbc");
Connection con = ds.getConnection();
The lookup results in the following Exception
com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException:
Object not found in lookup of myApp/jdbc/datasources/direct_jdbc.
I really don't see why this is not working. The datasource is defined and the JNDI-path looks ok to me. Why does the lookup fail?
Any answers are highly appreciated.
best regards
Marcel
Hi Marcel,
You say, you define the DataSource in a
persistent.xml
which is defined only for CMP Entity EJBs.
I have a feeling, you look up the so defined DataSource from another component like a servlet. Than you would have to set a reference from the web application to the bean and the lookup would work over the local JNDI reference (something like
java:comp/env/jdbc/<DS_Name>
... check the specification!)
I do not think you are looking the DataSource up from a remote client, since the InitialContext would have to be obtained with properties (you would also get a different exception) - beyond the fact, that looking a DataSource from a remote client is forbidden (as far as I know - I might be wrong here).
Other than that, both lookups:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/direct_jdbc");
Connection con = ds.getConnection();
as well as
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("jdbc/myApp/jdbc/datasources/direct_jdbc");
Connection con = ds.getConnection();
should actually work. Hmm ... are you sure about the "right" JNDI context?
Cheers, Goran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.