Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JNDI - javax.naming.NameNotFoundException

843830Oct 14 2008
*
Hi,*
I am new to JNDI. I am trying to execute the below mentioned code eg given in help topic in sun website.

** Included JAR files[fscontext.jar, provideutil.jar]*
** passing /classes as command line argument as mentioned in that example.[not sure its the right way]*
** I am using RAD to compile and execute the application.*

*import javax.naming.Context;

**
import javax.naming.InitialContext;

**
import javax.naming.NamingException;

**
import java.util.Hashtable;

**
import com.sun.jndi.fscontext.RefFSContextFactory;

**
public class Resolve {

*

public static void main(String argv[]) {


// The user should provide a file to lookup


if (argv.length != 1) {


System.+err+.println("Usage: java Resolve ");


System.+exit+(-1);


}





String name = argv[0];





// Here we use the file system service provider


Hashtable env = new Hashtable();


env.put(Context.+INITIAL_CONTEXT_FACTORY+, "com.sun.jndi.fscontext.RefFSContextFactory");





try {


// Create the initial context


Context ctx = new InitialContext(env);


System.+out+.println("1");


// Look up an object


Object obj = ctx.lookup(name);


System.+out+.println("2");


// Print it out


System.+out+.println(name + " is bound to: " + obj);





// Close the context


ctx.close();


} catch (NamingException e) {


System.+err+.println("Problem looking up " + name + ": " + e);


}


}


}



Output:


1


Problem looking up /classes: javax.naming.NameNotFoundException:/classes

Could you please help me resolving this issue.
Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2008
Added on Oct 14 2008
0 comments
354 views