This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Websphere and the fly likes WSAD 5.1.0 - JNDI - Resource Ref. Could Not Be Located. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "WSAD 5.1.0 - JNDI - Resource Ref. Could Not Be Located." Watch "WSAD 5.1.0 - JNDI - Resource Ref. Could Not Be Located." New topic
Author

WSAD 5.1.0 - JNDI - Resource Ref. Could Not Be Located.

Renuka G
Greenhorn

Joined: Oct 30, 2003
Posts: 22
I am using WSAD 5.1.0 and when i tried to explore the JNDI with a simple JSP page, which connects to a SQLServer database and displays records from a table,
the JSP page is producing the expected result - displaying records. But in the server's console window, I am seeing the following error message:
"Resource reference jdbc/ds1 could not be located, so default values of the following are used: [Resource-ref settings]".
*********************************************************************
And the code snippet goes here:
*********************************************************************
<%
Statement stmt = null;
InitialContext ctx = null;
DataSource ds = null;
Connection con = null;
try {
ctx = new InitialContext();
ds = (DataSource)ctx.lookup("jdbc/ds1");
}
catch (Exception e) {
System.out.println( e.toString() );
}

try {
con = ds.getConnection("userid", "password");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(
"select * from stocks");
%>
*********************************************************************
Eventhough i get the results, i need to get rid of this error.
Need your help on what is causing this.
Attached is the data source settings' image.
Thanks and regards,
Renuka
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Renuka
Open your web.xml and go to Reference tab. Select Resource.
Then on the left side enter the JNDI Name you want to code in the program. Lets say jdbc/dsName. Now on the right side, select object of time "javax.sql.DataSource" and make sure when you do this, you are not selecting "javax.activation.DataSource".
Next, extreme below, give the JNDI name u gave while configuring the datasource, jdbc/ds1. Thats it.
In ur code now u want to say "java:comp/env/jdbc/dsName" instead of the real JNDI Name "jdbc/ds1".
Got it? It is called "Resource-ref" bindings...
Renuka G
Greenhorn

Joined: Oct 30, 2003
Posts: 22
Thanks a lot, Mahesh.
Regards,
Renuka
Renuka G
Greenhorn

Joined: Oct 30, 2003
Posts: 22
Mahesh,
After that,
Now, i am getting the message:
"Component-managed authentication alias not specified for connection factory or datasource ds1."
Is this OK/normal? Or do i need to configure further anything? Thought it is meaningful for EJBs only???
Thanks,
Renuka
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Do this:
Under Server configuration , go to Security, and under JAAS Authentication entries,
Create a new alias by clicking add.
Give any name u want, and enter the userid and password who is authorized to access the datasource.
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
And then, go back to the Datasource tab and select this alias from the list.
Renuka G
Greenhorn

Joined: Oct 30, 2003
Posts: 22
Thanks, Mahesh.
Renuka G
Greenhorn

Joined: Oct 30, 2003
Posts: 22
Because of EJBs' distributed nature, any EJB from one location can call any EJB from another location and the location is transparent.
In my example, i am using JDBC resource and accessing it thru the JNDI. If it is an EJB access thru JNDI, i do not know how the EJBs are located internally... because during the JNDI entry configuration i made, EJBs JNDI names are not prefixed with DNS name/IP Addresses. Then, how are the EJBs located?
Need help/advise to refine my understanding in this regard.
Thanks and regards,
Renuka
Mahesh Chalil
Ranch Hand

Joined: Jan 24, 2002
Posts: 147
Read about local naming service in each server process in websphere 5.0
Shahnawaz Sabuwala
Greenhorn

Joined: May 25, 2004
Posts: 2
Hi,

How do I create a resource reference to my MySQL Datasource in WebSphere Application Server v5.1 ?

I have configured it in WAS and assigned a JNDI name of 'jdbc/MySQLDataSource' to it using the administration console. However, I cannot find a place where I can map a resource reference to my JNDI name.

Say, for example, if I create the resource reference as explained above in my web.xml, will I need to create additional entries in other files (analogous to server.xml in Tomcat? or is that already taken care of when I created the data source in WAS?)

Regards,
Shahnawaz
Jack The Ripper
Greenhorn

Joined: Sep 01, 2004
Posts: 5
Thank ! for information. It save me ^_^'..
thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
I am facing same kind of problem.

An exception occurred while invoking method setDataSourceProperties on com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource Data source 1 : java.lang.reflect.InvocationTargetException


1. I have added parameters as mentioned above in web.xml and ibm-web-bnd.xml files and created JNDI name using Server persepective of WSAD 5.1.2.
Whatelese I need to get the connection?

Can anybody help me out to solve the connectivity issue?

It would be great help,if you could send me the steps required for establishing the connection with help of JNDI Look Up using WSAD 5.1.2.


Thanks in advance,
Tom.
thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
I got 10 exceptions and i am sending all those exceptions
1)An exception occurred while invoking method setDataSourceProperties on com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource Data source 1 : java.lang.reflect.InvocationTargetException
2)An exception occurred while trying to instantiate the ManagedConnectionFactory class com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource jdbc/sample : java.lang.reflect.InvocationTargetException
3)A Reference object looked up from the context "localhost/nodes/localhost/servers/server1" with the name "jdbc/sample" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
4)Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. Root exception is java.lang.reflect.InvocationTargetException
5)An exception occurred while invoking method setDataSourceProperties on com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource Data source 1 : java.lang.reflect.InvocationTargetException
6)An exception occurred while trying to instantiate the ManagedConnectionFactory class com.ibm.ws.rsadapter.spi.WSManagedConnectionFactoryImpl used by resource jdbc/sample : java.lang.reflect.InvocationTargetException
7)A Reference object looked up from the context "localhost/nodes/localhost/servers/server1/jdbc" with the name "sample" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
8)A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
9)A Reference object looked up from the context "java:" with the name "comp/env/jdbc/sample" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
10)A NamingException is being thrown from a javax.naming.Context implementation. Details follow:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WSAD 5.1.0 - JNDI - Resource Ref. Could Not Be Located.
 
Similar Threads
Can I connect to database at runtime from WSAD5.0?
Datasource could not be located in Websphere5.0 connecting with SQL Server
JNDI Resource Bindings
Connection class related Query
error in context lookup