• 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

javax.naming.reference exception on lookup

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a POJO which returns a database connection.I have the following code in my class to get the connection.

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext initialContext = new InitialContext(env);
dataSource = (DataSource) initialcontext.lookup("jdbc/sqlserver_mydb");

[/code]

I have added references for this in the web.xml. I have added in the datasources also.

Once my server is running, I am trying to run my POJO as an application.
But this gives me a classcastexception: javax.naming.namingreference at

dataSource = (DataSource) initialcontext.lookup("jdbc/sqlserver_mydb");


It would be very helpful if someone could help me understand where i am going wrong.

thanks in advance

rgds
Mahesh
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the complete exception trace.
 
reply
    Bookmark Topic Watch Topic
  • New Topic