Issues while trying to create JNDI Context in Glassfish
872285Jun 29 2011 — edited Jun 30 2011I believe I have searched this all across google but I didn't find a satisfactory answer so posting here to ask the question.
/*
* Create a JNDI API InitialContext object if none exists
* yet.
*/
try {
jndiContext = new InitialContext();
} catch (NamingException e) {
System.out.println("Could1 not create JNDI API " +
"context: " + e.toString());
e.printStackTrace();
System.exit(1);
} catch (Exception e) {
System.out.println("Exception. Could not create JNDI API " +
"context: " + e.toString());
e.printStackTrace();
System.exit(1);
}
System.out.println("JNDI Created");
Above is the code that is throwing exceptions
Could1 not create JNDI API context: javax.naming.NoInitialContextException: Cann
ot instantiate class: com.sun.enterprise.naming.impl.SerialInitContextFactory [R
oot exception is java.lang.NullPointerException]
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterp
rise.naming.impl.SerialInitContextFactory [Root exception is java.lang.NullPointerException]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at examples.simple.SimpleQueueSender.main(SimpleQueueSender.java:93)
Caused by: java.lang.NullPointerException
at com.sun.enterprise.module.single.ManifestProxy.<init>(ManifestProxy.java:75)
at com.sun.enterprise.module.single.ProxyModuleDefinition.<init>(ProxyModuleDef
inition.java:78)
at com.sun.enterprise.module.single.ProxyModuleDefinition.<init>(ProxyModuleDef
inition.java:73)
at com.sun.enterprise.module.single.SingleModulesRegistry.<init>(SingleModulesR
egistry.java:79)
at com.sun.enterprise.module.single.SingleModulesRegistry.<init>(SingleModulesR
egistry.java:67)
at com.sun.enterprise.module.single.StaticModulesRegistry.<init>(StaticModulesR
egistry.java:66)
at org.glassfish.internal.api.Globals.getStaticHabitat(Globals.java:84)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.<init>(SerialInitCon
textFactory.java:236)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 5 more
Earlier while researching a previous issue, ManifestProxy was earlier not able to find "findResouces" method so with older versions of jar it was giving a different issue. I checked the latest version, not sure how the change in code could have resolved the issue. Seems earlier the error was NoMethodFoundException and now that has been caught and now it is throwing NullPointerException.
Did any of you face this issue and can help? I have all the classes from GLASSFISH_HOME/lib and GLASSFISH_HOME/module in my classpath.