• 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

JNDI lookup of datasource in a standalone application

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,
I am trying to access a datsource from a standalone application.
I am using websphere 6.1.
My code is as follows -

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(Context.PROVIDER_URL, "iiop://localhost:8880");
Context initialContext = new InitialContext(env);
DataSource ds = (DataSource)initialContext.lookup("jdbc/icareSouthOracle");
System.out.println("Hi...."+ds);
}
catch (NamingException e) {
e.printStackTrace();
}

I am getting an exception -
Exception in thread "main" java.lang.NoSuchMethodError: com/ibm/ws/bootstrap/WSLauncher.isZOS()Z
at com.ibm.ws.orb.GlobalORBFactory.readProperties(GlobalORBFactory.java:166)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:85)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:174)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:97)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:73)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:386)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:305)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:375)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:113)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:428)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:144)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at MySample.main(MySample.java:29)

Please can you tell me what exactly is going wrong here.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am a little confused by the error ... but can you try to change your classpath to the bootstrap.jar in the lib directory and see if that clears up the problem.

The method is defined there ... by the message it would appear that you are getting a different copy of the class. If that fails to work, I would turn on verbose classloading and see where the class is getting loaded from.

C:\WASHOME\lib>..\java\bin\javap -classpath ./bootstrap.jar com/ibm/ws/bootstrap/WSLauncher
Compiled from "WSLauncher.java"
public class com.ibm.ws.bootstrap.WSLauncher extends java.lang.Object{
public static boolean debug;
public static java.io.PrintStream out;
static final java.lang.String WAS_PROPERTY_FILE;
public com.ibm.ws.bootstrap.WSLauncher();
public static void main(java.lang.String[]);
public static boolean isZOS();
public static boolean isISeries();
public static boolean isWindows();
public static void debug(java.lang.String);
static void onExit();
public static void doPreload(java.lang.String[], com.ibm.ws.bootstrap.ExtClassLoader);
static {};
}
 
Pooja Shah
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks F Malin!!
It turns out the problem was in the classloading sequence.
But now, I get a SocketException... although my server is started.
I had select SOAPPort 8880 on my Websphere server. So i selected the RMI port 2809.
But the same result.. any ideas ???
 
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you try following code snippet and see if you can lookup the datasource?

Replace "<<boot strap address port>>" with boot strap address, which is typically 2809 for base server.
Replace "<<jndi of oracle datasource>>" with the JNDI of the Oracle datasource from WAS.

Also I am assuming that the "Test Connection" button is working for you in the WAS Integrated Service Console.



Let me know.
 
reply
    Bookmark Topic Watch Topic
  • New Topic