String className = (String) env.get(Context.INITIAL_CONTEXT_FACTORY);
if (className != null) {
try {
factory = (InitialContextFactory) Class.forName(className).newInstance();
} catch (Exception e) {
NoInitialContextException ne = new NoInitialContextException("Cannot instantiate class: " + className);
ne.setRootCause(e);
throw ne;
}
}
}
if (factory == null) {
NoInitialContextException ne = new NoInitialContextException(
"Need to specify class name in environment or system " +
"property, or as an applet parameter, or in an " +
"application resource file: " +
Context.INITIAL_CONTEXT_FACTORY);
throw ne;