我在Netbeans中创建了一个简单的企业应用程序,它在Netbeans中按预期工作。企业应用程序客户端包含以下代码:无法实例化类:com.sun.enterprise.naming.SerialInitContextFactory
package clienttest2;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import test.TestEJBRemote;
/**
*
* @author
*/
public class Main {
private TestEJBRemote testejb;
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws NamingException {
Properties props = new Properties();
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");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "computer");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ctx = new InitialContext(props);
TestEJBRemote t = (TestEJBRemote) ctx.lookup("java:global/EJBTest/EJBTest-ejb/TestEJB");
System.out.println(t.getName("Ian"));
//Context ctx = null;
//ctx=new InitialContext();
//TestEJBRemote t = (TestEJBRemote) ctx.lookup("java:global/EJBTest/EJBTest-ejb/TestEJB");
//System.out.println(t.getName("Ian"));
}
}
我曾尝试以下:
java -jar ClientTest.jar
我得到的错误是:无法实例类:com.sun.enterprise.naming.SerialInitContextFactory
我有几个问题:
我在我的电脑上安装了JRE 1.8。这是否意味着我可以运行所有类型的Java应用程序,即Java EE和Java SE?
glassfish的appclient命令可能为您解决这些依赖关系。 – Thufir