• 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

Lookup problem for StandaloneApplication with Websphere 6.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi This is my first discussion. Coming to the topic, I have created a Data Source (DB2) in WebSphere. JNDI name has been configured. I have done the Standalone application and got over. The question is how to LOOKUP JNDI name for the StandAlone application and how to ACCESS?
The program is as follows(code snippet):

class DBConnect4 {

public static void main(String[] args) throws NamingException, SQLException {

Properties props = new Properties();

props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
/*props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");*/
// --------------------the problem occurs here------------------------------------
// --------------------at props.put(Context.PROVIDER_URL,"iiop://............
props.put(Context.PROVIDER_URL, "iiop://172.23.99.88:9064");//172.23.99.88
System.out.println("The Connection is" + props);
try {
InitialContext initContext = new InitialContext(props);
Object obj = initContext.lookup("jdbc/myDataSource");

DataSource ds = (DataSource) obj;
Connection connection = ds.getConnection("db2admin", "123$");

System.out.println("Connection estblished");




I have configured everything, instead I am getting the following error:

The Connection is{java.naming.provider.url=iiop://172.23.99.88:9064, java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory}
The Exception is:Failed to initialize the ORB
javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.ClassCastException: com.sun.corba.se.impl.orb.ORBImpl]
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:318)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:392)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:117)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:712)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:171)
at javax.naming.InitialContext.lookup(Unknown Source)
at src.DBConnect4.main(DBConnect4.java:27)
Caused by: java.lang.ClassCastException: com.sun.corba.se.impl.orb.ORBImpl
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:86)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:179)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:83)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:59)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:102)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:309)
... 6 more
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try the below.also make sure that you have required jars in classpath

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:2809");
try {
initialContext = new InitialContext(env);
 
reply
    Bookmark Topic Watch Topic
  • New Topic