环境:JDK1.6,Eclipse3.5,weblogic10,MyEclipse8.5
客户端代码:
public static void main(String[] args) {
EjbTestClient app = new EjbTestClient();
Properties prop = null;
try {
prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
        prop.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
app.ctx = new InitialContext(prop);
System.out.println("连接应用服务器成功");
StatelessSessBeanTestRemote remote = (StatelessSessBeanTestRemote) app.ctx.lookup("sstr#"+StatelessSessBeanTestRemote.class.getName());
System.out.println(remote.interfaceMeth());
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "连接应用服务器失败:\n"+e.toString()+"\n\n程序即将退出!");
}
System.exit(0);
}
在Eclipse中运没有问题,编写批处理文件如下:
java -cp ".;EJB3_01.jar;wlfullclient.jar;client.jar" client.EjbTestClient
在Eclipse工作空间该项目的目录下运行没问题,但拷贝到其它目录中运行就报错:
E:\测试>C:\jdk1.6\bin\java -cp ".;wlfullclient.jar;EJB3_01.jar;client.jar" clien
t.EjbTestClient
actionPerformed()
连接应用服务器成功
test.StatelessSessBeanTestRemote
Exception in thread "AWT-EventQueue-0" java.lang.AssertionError: java.lang.Class
NotFoundException: test.StatelessSessBeanTestRemote不知道是什么原因,请高人指点,谢谢!

解决方案 »

  1.   

    StatelessSessBeanTestRemote remote = (StatelessSessBeanTestRemote) app.ctx.lookup("sstr#"+StatelessSessBeanTestRemote.class.getName());在这把package名也拼进去
      

  2.   

    你debug一下,看看
    sstr#"+StatelessSessBeanTestRemote.class.getName()弄出个什么东西。另外,你的EJB容器是什么?到那去看看你的EJB类是不是被正常发布了
      

  3.   

    你确定你的test.StatelessSessBeanTestRemote在client.jar里面?
    或者在其他的cp指定的jar里面?
    client.jar就在你的【E:\测试】路径下?还有,你的这个错误与下面代码中lookup是没有关系的。
    也就是说:那么你System.out.println(StatelessSessBeanTestRemote.class.getName());也会出CNF。
    --
    StatelessSessBeanTestRemote remote = (StatelessSessBeanTestRemote) app.ctx.lookup("sstr#"+StatelessSessBeanTestRemote.class.getName());