home=(ConverterHome)(objref);
是不对的,删除好了。
home =(ConverterHome)PortableRemoteObject.narrow(objref, ConverterHome.class); 
好象并没有问题的,现在提示说narrow回来的东西转到ConverterHome时出错,是不是你的配置文件有问题?以下的是对的:
.......
Context initial = new InitialContext(); 
Object objref=null;
objref = initial.lookup("MyConverter"); ConverterHome home=null;home =(ConverterHome)PortableRemoteObject.narrow(objref, ConverterHome.class); 
Converter currencyConverter = home.create(); 
.......不过如果你用的是weblogic等服务器,InitialContext的构造函数还应该传一个属性进去。

解决方案 »

  1.   

    我用的是deploytool部署的
    你的那个我试过啊 它提示
    java.lang.ClassCastException
            at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Porta
    bleRemoteObject.java:293)
            at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
            at ConverterClient.main(ConverterClient.java:26)
    错误,郁闷ing
      

  2.   

    是用的j2ee adk和deploytool么?
      

  3.   

    这样试试objref = initial.lookup("java:comp/env/ejb/MyConverter");
      

  4.   

    对,就是用J2EE的deploytool的我待会试一试objref = initial.lookup("java:comp/env/ejb/MyConverter");郁闷死了,ft,吃饭先,呵呵
      

  5.   

    这样试试objref = initial.lookup("java:comp/env/ejb/MyConverter");
    哎,也不可以,提示:
    Caught an unexpected exception!
    javax.naming.NamingException: java:comp/env namespace is only available from wit
    hin a J2EE component
            at com.sun.enterprise.naming.java.javaURLContext.getComponentContext(jav
    aURLContext.java:395)
            at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j
    ava:51)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at ConverterClient.main(ConverterClient.java:13)
      

  6.   

    更正一下,其实应该是你部署时设置的名字如果没有加路径就试试objref = initial.lookup("java:comp/env/MyConverter");我的jndi名字设的是ejb/MyConverter,所以才会是上面说的那个路径。
      

  7.   

    运行 deploytool左边选择部署的ejb , 右边 <<security tab>> -> <<Deployment Setting>>
    选<<support client choice>>, 然后redeploy
      

  8.   

    更正一下,其实应该是你部署时设置的名字如果没有加路径就试试objref = initial.lookup("java:comp/env/MyConverter");我的jndi名字设的是ejb/MyConverter,所以才会是上面说的那个路径。提示:
    Caught an unexpected exception!
    javax.naming.NamingException: java:comp/env namespace is only available from wit
    hin a J2EE component
            at com.sun.enterprise.naming.java.javaURLContext.getComponentContext(jav
    aURLContext.java:395)
            at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.j
    ava:51)
            at javax.naming.InitialContext.lookup(InitialContext.java:347)
            at ConverterClient.main(ConverterClient.java:13)
      

  9.   

    运行 deploytool左边选择部署的ejb , 右边 <<security tab>> -> <<Deployment Setting>>
    选<<support client choice>>, 然后redeploy提示:
    class com.sun.corba.ee.internal.iiop.CDRInputStream_1_0$1
    interface ConverterHome
    Caught an unexpected exception!
    java.lang.ClassCastException
            at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Porta
    bleRemoteObject.java:293)
            at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
            at ConverterClient.main(ConverterClient.java:19)
      

  10.   

    lookup?narrow?请问是什么意思?我刚学,找了好几个helloworld照着做,就是没有成功
      

  11.   

    你没有在home里面throws UnicastRemoteobject ?
    而且你一个home 变量居然既是skeletch,又是homebean,我觉得有点糊涂。
      

  12.   

    你的ejb class有多份所以它ClassCastException,请保证只有一份Class在一个jvm中