InitialContext « jndi « Java Enterprise Q&A

1. How to mock the InitialContext class with jmockit?

I'm using jmockit with my tests and with one class I wish to test, uses InitialContext directly. So I have the following:

public class MyClass {
  public void myMethod() {

2. Can I build a directory structure (JNDI) with the file based context factory com.sun.jndi.fscontext.RefFSContextFactory

Using the com.sun.jndi.fscontext.RefFSContextFactory file based JNDI context factory and it seems to only allow 1 binding file in location you specify. For example

Hashtable properties = new Hashtable(2);
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new ...

3. Is it possible to get "everything" from javax.naming.InitialContext?

Is it possible to retrieve "everything" (all names) from javax.naming.InitialContext? I didn't find any examples or documentation about it.

4. javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable

I have small program which just creating intial context in unmanaged environment i.e. outside the container.I have been using Websphere 7.0. I have written following program to do the connection with application ...

5. JNDI + InitialContext stuff vs Reflection

THRILLA IN MANILLA RUMBLE IN THE JUNGLE two superstars face off: Reflection API vs JNDI I hear there is more than one way to skin a cat wheneve ryou do any kind of software programming.. Do I use while or for loop, switch case or an if else etc etc etc. And they don't really matter. Is this one of those ...

6. JNDI InitialContext Question.