• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

InitialContext WebSphere 3.5.4

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Shireen Loke
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3892
5
Redhat Quarkus Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Klye,
I have checked as you have suggested. However, I got "segmentation fault" after adding rt.jar to my CLASSPATH. Any idea?
Shireen
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic