| 发表于:2007-05-10 16:41:34 楼主 |
ide:netbeans ejb 容器:system application server ejb 3.0 接口 /* * homer.java * * created on 2007年5月10日, 下午1:54 * * to change this template, choose tools ¦ template manager * and open the template in the editor. */ package first; import javax.ejb.remote; /** * * @author administrator */ @remote public interface homer { string hello(string user); } sessionbean: /* * hello.java * * created on 2007年5月10日, 下午1:56 * * to change this template, choose tools ¦ template manager * and open the template in the editor. */ package first; import javax.ejb.stateless; /** * * @author administrator */ @stateless public class hello implements homer{ /** creates a new instance of hello */ public hello() { } public string hello(string user) { return "hello " +user; } } 客户端: /* * main.java * * created on 2007年5月10日, 下午1:59 * * to change this template, choose tools ¦ template manager * and open the template in the editor. */ package test; import first.homer; import javax.naming.context; import javax.naming.initialcontext; import javax.naming.namingexception; /** * * @author administrator */ public class main { /** creates a new instance of main */ public main() { } /** * @param args the command line arguments */ public static void main(string[] args) throws exception { // todo code application logic here context context=new initialcontext(); homer home=(homer)context.lookup( "first.homer "); system.out.println(home.hello( "yuchen ")); } } 错误提示:exception in thread "main " javax.naming.namenotfoundexception: first.homer not found |
|
|
|
|