在ejb-jar.xml <ejb-ref> <description> an EJB reference to the Widget EJB(描述)</description> <ejb-ref-name>ejb/WidgetEJB</ejb-ref-name> <ejb-ref-type>session</ejb-ref-type> <home>com.dhc.WidgetHome</home> <remote>com.dhc.Widget</remote> </ejb-ref>
程序 Content ctx = new InitialContent(); Object h = ctx.lookup("java:/comp/env/ejb"); //環境變量是只讀的,而且是當前ejb的本地變量. WidgetHome home = (WidgetHome)PortableRemoteObject.narrow(h,WidgeHome.class);