我添加了以下的罐子:
只要我在netbeans中运行独立应用程序,一切正常!
但是当我从外部netbeans运行它时,我得到了这个错误:
java.lang.noClassDefFoundError:org / glassfish / internal / api / Globals
我的问题:我如何知道申请所需的罐子清单?
以下是代码:
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.swing.JOptionPane;
import packageApp.SessionBeanSingletonInterface;
.....
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// glassfish default port value will be 3700,
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx;
try {
ctx = new InitialContext(props);
SessionBeanSingletonInterface bean = (SessionBeanSingletonInterface) ctx.lookup("packageApp.SessionBeanSingletonInterface");
System.out.println(bean.getMessage());
} catch (NamingException ex) {
Logger.getLogger(JavaApplicationUsingEJB.class.getName()).log(Level.SEVERE, null, ex);
}