我试图连接到通过Java Web Start GlassFish服务器EJB服务。 我收到以下错误,同时获得初始上下文。 我还添加了代码段用于获取初始上下文。
一个有趣的是,当我在NetBeans IDE中运行该程序的一个简单的Java程序Java Web Start的之外,它工作正常。
我添加了所有从GlassFish模块相关的jar文件夹到Java Web Start的。
java.lang.NullPointerException
at com.sun.enterprise.naming.impl.SerialContext.<init>(SerialContext.java:275)
at com.sun.enterprise.naming.impl.SerialContext.<init>(SerialContext.java:334)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.createInitialContext(SerialInitContextFactory.java:358)
at com.sun.enterprise.naming.impl.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:353)
at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:69)
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 gov.ca.lc.util.ServiceLocator.getInitialContext(ServiceLocator.java:140)
at gov.ca.lc.util.ServiceLocator.getVotesEJB(ServiceLocator.java:103)
at gov.ca.lc.scenemanagement.AbstractVotingScene.getCommitteeList(AbstractVotingScene.java:143)
at gov.ca.lc.scenemanagement.AbstractVotingScene.<init>(AbstractVotingScene.java:65)
at gov.ca.lc.scenes.MenuScene.<init>(MenuScene.java:56)
at gov.ca.lc.menu.StartVoting.startUp(StartVoting.java:47)
at org.mt4j.MTApplication.setup(MTApplication.java:328)
at processing.core.PApplet.handleDraw(PApplet.java:1580)
at processing.core.PApplet.run(PApplet.java:1502)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Animation Thread" java.lang.NullPointerException
at gov.ca.lc.scenemanagement.AbstractVotingScene.getCommitteeList(AbstractVotingScene.java:143)
at gov.ca.lc.scenemanagement.AbstractVotingScene.<init>(AbstractVotingScene.java:65)
at gov.ca.lc.scenes.MenuScene.<init>(MenuScene.java:56)
at gov.ca.lc.menu.StartVoting.startUp(StartVoting.java:47)
at org.mt4j.MTApplication.setup(MTApplication.java:328)
at processing.core.PApplet.handleDraw(PApplet.java:1580)
at processing.core.PApplet.run(PApplet.java:1502)
at java.lang.Thread.run(Unknown Source)
Following is my code to get the initial context
private static InitialContext getInitialContext()
throws NamingException {
Properties props = null;
try{
// props=new Properties();
// props.load(new FileInputStream(new File("jndi.properties")));
// System.out.println(props.get("java.naming.factory.initial"));
props=new Properties();
props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs ", "com.sun.enterprise.naming");//ur server ip
props.setProperty("java.naming.factory.state ", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");//ur server ip
props.setProperty("org.omg.CORBA.ORBInitialHost", "165.107.33.181");//ur server ip
props.setProperty("org.omg.CORBA.ORBInitialPort","3700"); //default is 3700
}catch(Exception ex){
ex.printStackTrace();
}
return new InitialContext(props);
}