I tried to list all EJB deployed on a IBM WebSphere server 3.0.2 with
javax.naming.Context.list instruction.
I get this error :
Exception in thread "main" java.lang.IncompatibleClassChangeError
at com.ibm.ejs.ns.jndi.CNContextImpl.doList(CNContextImpl.java:1104)
at com.ibm.ejs.ns.jndi.CNContextImpl.list(CNContextImpl.java:482)
at javax.naming.InitialContext.list(InitialContext.java:406)
at tst.main(tst.java:32)
Where is the mistake ?
I am sure that my context is good, i'm able to lookup an EJB.
If anyone can help me.
Thanks
Here is my client code :
Context c = getJndiContext("", "192.168.0.146", "900", "", "");
c.list("");
static Context getJndiContext(String protocol, String host, String port,
String user, String password) throws NamingException {
Properties prop = System.getProperties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
prop.put(Context.PROVIDER_URL, "iiop://" + host + ":" + port);
prop.put(ORBCLASS_SYSPROP, ORBCLASS_NAME);
return new InitialContext(prop);
}
// Do the JNDI lookup and dump the contents
Hashtable parms = new Hashtable(2);
parms.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
parms.put(Context.PROVIDER_URL, "iiop://" + hostName + ":" + hostPort);
try {
Context context = new InitialContext(parms);
// check input parameters for actions to take (add, remove)
if (request.getParameter("addName") != null) {
String nameToAdd = request.getParameter("addName");
if (!"".equals(contextName))
nameToAdd = contextName + '/' + nameToAdd;
try {
context.bind(nameToAdd,nameToAdd);
} catch (NamingException ignored) {}
} // addName
else if (request.getParameter("removeName") != null) {
String nameToRemove = request.getParameter("removeName");
try {
context.unbind(nameToRemove);
} catch (NamingException ignored) {}
} // removeName
// dump all names
NamingEnumeration jndiNames = context.list(contextName);
if (jndiNames.hasMoreElements()) {
%>
<table border=1>
<tr><th>Class Name</th><th>Name</th><th>Action</th></tr>
<%
while (jndiNames.hasMoreElements()) {
NameClassPair namePair = (NameClassPair)jndiNames.nextElement();
String className = namePair.getClassName();
String fullname = namePair.getName();
.....
Ken