aj cec

Greenhorn
+ Follow
since Feb 05, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by aj cec

thanks =) ill look into it.
20 years ago
Can anyone help. I have this code. I am using Websphere v5.1
public class EjbUtils {

public static Context getInitialContext()throws NamingException{
Hashtable hash = new Hashtable();
hash.put (Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
hash.put(Context.PROVIDER_URL,"iiop://localhost/9080");
return new InitialContext(hash);
}
______
public class JndiExplorer {
public static void main(String args[]){
Context ctx = null;
try{
ctx = EjbUtils.getInitialContext();
bindTestObject(ctx);
listBindings("",ctx);
}catch(Exception e){
e.printStackTrace();
}

}

private static void bindTestObject(Context context)throws NamingException{
List testBinding = new LinkedList();
testBinding.add("bound string");
testBinding.add(new Integer(2));
context.bind("test binding",testBinding);
}

private static void listBindings(String name,Context context)throws NamingException{
NamingEnumeration bindings = null;
String fullName = null;
try{
bindings = context.listBindings(name);
}catch(CannotProceedException e){
return;
}catch(Exception e){
return;
}
while(bindings.hasMore()){
NameClassPair binding = (NameClassPair)bindings.next();
fullName = name.equals("") ? binding.getName() : name + "." + binding.getName();
System.out.println("\r\nJNDI name : '" + fullName + "'");
}
try{
Object boundObject = context.lookup(fullName);
System.out.println("bound object toString == '" + boundObject + "'");
}catch(Exception e){
e.printStackTrace();
}
}
}
it displays an error:
javax.naming.NamingException: Failed to initialize the ORB. Root exception is java.lang.ClassNotFoundException: com.ibm.ejs.oa.EJSORB
at java.net.URLClassLoader.findClass(URLClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:516)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:441)
at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:142)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:266)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:364)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408)
at com.ibm.ws.naming.util.WsnInitCtx.bind(WsnInitCtx.java:151)
at javax.naming.InitialContext.bind(InitialContext.java:367)
at JndiExplorer.bindTestObject(JndiExplorer.java:36)
at JndiExplorer.main(JndiExplorer.java:24)
I have already included naming.jar (where the WsnInitialContextFactory is) and namingclient.jar (where the jndiproperties.properties is).
What seems to be the problem? thank you.
20 years ago