File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes InitialContext WebSphere 3.5.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "InitialContext WebSphere 3.5.4" Watch "InitialContext WebSphere 3.5.4" New topic
Author

InitialContext WebSphere 3.5.4

Shireen Loke
Greenhorn

Joined: Jan 05, 2002
Posts: 12
Hi,
I am using WebSphere Standard Edition V3.5.4 on Linux. I am having problem with connection pooling. For your information, the following is my code:
--------Start---------------
package common;
import javax.sql.*;
import javax.naming.*;
import com.ibm.ejs.dbm.jdbcext.*;
import com.ibm.ejs.ns.jndi.*;
import java.sql.*;
import java.util.*;import com.ibm.websphere.advanced.cm.factory.*;

public class DataBean
{
private final String DATASOURCE = "MyDatasource";

public Connection getConnection()
{
Connection conn = null;
DataSource ds = null;
try
{
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");
parms.put(Context.PROVIDER_URL,"iiop://sdlinux:900");
Context context = new InitialContext(parms);
ds = (DataSource)context.lookup(DATASOURCE);
conn = ds.getConnection("username","password");
}
catch (Exception t)
{
// DataSource not found. Throw Exception
}
finally {
}
return conn;
}

}

------- End ----------------------
My problem is as follows:
java.lang.NoClassDefFoundError: Lcom/ibm/CORBA/iiop/ORB;
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
71)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242
)
at javax.naming.InitialContext.init(InitialContext.java:218)
at javax.naming.InitialContext.<init>(InitialContext.java:194)
at common.DataBean.getConnection(DataBean.java:38)
at TestConn.main(TestConn.java:11)
Could anyone tell me what is the problem with the InitialContext?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Let me guess -- you're trying to run a Java client that uses connection pooling right? In other words this code is NOT part of a servlet...
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Shireen Loke
Greenhorn

Joined: Jan 05, 2002
Posts: 12
Kyle,
You are right. This is not a servlet. What I was trying to do was that to create a common function where I can get a connection. I can successfully get connections without using connection pooling, but failed when I do so.
The code fragment listed on the previous posting is what I copied from IBM websites. I have tried different ways but in vain. Do you have any idea as to how I could tackle this problem? I would truly appreciate for your help.
Shireen
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Hmmm... So are you testing this from a program in the Java command line? If so then the problem is probably that (a) you're not using the IBM JVM (which is absolutely REQUIRED to use any of this from a Java client -- use the one that ships with WebSphere) and (b) you've not included all of the WebSphere libraries (.jar files) in your classpath.
If you're building a common function library -- just try testing it within a servlet instead of from a command-line program and everything should be fine.
Kyle
Shireen Loke
Greenhorn

Joined: Jan 05, 2002
Posts: 12
Kyle,
Thanks for reminding me of the CLASSPATH setting. I have just included all the jar files needed for connection pooling and checked that I am currently using IBM JVM. Yet still I got the following errors.
_______________________________________
can't instantiate default ORB implementation com.sun.rmi.corba.ORBSingleton min
or code: 0 completed: No]
at com.ibm.ejs.oa.EJSO
_______________________________________

This is the part that cause this error.
->>
Context context = new InitialContext(parms);
Could you kindly give me a little more input ? Thank you very much.
Shireen
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Double-check your classpath. On this thread I provide an example classpath that contains all the JAR files you need, in the right order (important).
Kyle
Shireen Loke
Greenhorn

Joined: Jan 05, 2002
Posts: 12
Klye,
I have checked as you have suggested. However, I got "segmentation fault" after adding rt.jar to my CLASSPATH. Any idea?
Shireen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InitialContext WebSphere 3.5.4
 
Similar Threads
Initial Context problem
IBM Websphere 5 Connection Pool
Problem in Accessing DataSource in websphere
Probelm in connection pool
CONNECTION POOL in WAS 3.5