• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

regarding simple JNDI program

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All.,

I have written a simple JNDI program in IBM RAD.While running its showing
"Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory " Exception. After that I have downloaded and included fscontext.jar in the libraries. But it`s showing another exception...

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jndi/toolkit/chars/CharacterEncoder

Here I am giving complete code.

package mypackage;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class NamingExample {

public static void main(String []l){
Hashtable environment=new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
try{
Context intialContext=new InitialContext(environment);
String name="D:\\sureshsai";
Object object=intialContext.lookup(name);
System.err.println("the name ... "+name+" is bound to "+object);
}catch (NamingException ne) {
System.err.println("naming exception was thrown... "+ne.getMessage());
}

}
}

Please help me to make the code runnable.
 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Are your jars on your classpath ?
2) then double check (unzip) that class in is the jars (it's meant to be).

Now possibly what is the problem ..

3) Check the class file (java) versions of the related classes eg if old java tries to link to new class files it'll say can't find the file when what it means is can't find a compatiable version so you need to check your Java version and the version of the class files in the two jars all are appropriate to work together ...

easiest way make sure the jars come from the same place and upgrade Java to the latest.

4) Failing that check they haven't done anything 'unique' in the MANIFEST.INF with regards to class paths etc etc
 
reply
    Bookmark Topic Watch Topic
  • New Topic