• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot, Mahesh.
Regards,
Renuka
 
Renuka G
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And then, go back to the Datasource tab and select this alias from the list.
 
Renuka G
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Mahesh.
 
Renuka G
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read about local naming service in each server process in websphere 5.0
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank ! for information. It save me ^_^'..
 
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 207
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
reply
    Bookmark Topic Watch Topic
  • New Topic