The usage pattern for JNDI is:
InitialContext initialContext = new InitialContext( env )
try {
// do something with the context;
}
catch ( Exception e ) {
// handle exceptions
}
finally {
// cleanup resources
initialContext.close();
}
In case a shared context is used (org.osjava.sj.jndi.shared=true) the second
client won't see any bound instances, since the first client (registering the
object) calls close() in its finally block.
The question really comes down to what the semantics of InitialContext#close()
is. The javadocs is not really clear about this. See also
http://stackoverflow.com/questions/5120961/context-and-initialcontext-should-i-b
e-calling-the-close-method-on-these-obje