对于J2EE自带的部署工具RI部署EJB时候,编写客户端测试程序总是出错?请教高手.
最近刚开始学习EJB,部署的时候还能成功!但是客户端程序就是测试不出来.
测试用的客户代码如下:
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import Simple.*;
public class TestSallary
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
try
{
Context ctx= new InitialContext();
Object obj = ctx.lookup("SalaryRemote");
SalaryRemoteHome home = (SalaryRemoteHome)PortableRemoteObject.narrow(obj, SalaryRemoteHome.class);
SalaryRemote salary= home.create();
System.out.println(salary.getSalary());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
报的错误如下:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at TestSallary.main(TestSallary.java:18)
请教高手.