ejb的bean布署中的一个烦人小问题

        首先介绍一下我的布署环境: web server :tomcat 5.5.26, ejb Server: jboss 4.2.2 ga, jdk: 1.5,其中开发的ejb布置在jboss中,然后写了一个jsp页面来调用ejb组件(该页面布置在tomcat下);          jsp页面的主要代码片断:                  Properties prots = new Properties();                                  prots.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");                      prots.setProperty("java.naming.provider.url","127.0.0.1:1099");                 InitialContext ctx = new InitialContext(prots);                      CustemerDao cd = (CustemerDao)ctx.lookup("CustemerDaoBean/remote");                   Custemer cs = new Custemer();          cs.setPname("fanyuli");          cs.setEmail("fycghy0803@163.com");          cs.setAddress("beijing china");          cs.setPay_type("2");          cs.setPersonid("fycghy0803");                  cd.insertCustemer(cs);                  List<Custemer> clist = cd.getCustemerList();          for(Custemer cus : clist){                           out.println("id = " + cus.getpersonid());                       out.println("name = " + cus.getPname());             }     然后测试代码,成功执行,然后我想把        Properties prots = new Properties();               prots.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");          prots.setProperty("java.naming.provider.url","127.0.0.1:1099");         中的环境变量的设置放在jndi.properties文件中,该文件放置在web应用的WEB-INFO/classess目录下,正常情况下ctx对象在创建中会自动加载该文件,然后读取其中的内容,对自身的环境参数进行设置.      jdni.properties文件中内容如下:                            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory                               java.naming.provider.url=172.24.44.209:1099       然后将jsp页面中的内容:           Properties prots = new Properties();                prots.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");                 prots.setProperty("java.naming.provider.url","127.0.0.1:1099");            InitialContext ctx = new InitialContext(prots);            改为 :                      InitialContext ctx = new InitialContext();        然后重新执行程序,出错了,错误内容如下:                javax.naming.NameNotFoundException: Name CustemerDaoBean is not bound in this Context        开始我认为是jsp页面中的ctx对象没有找到jndi.properties文件,就放了n个地方,结果仍然不行。      后来我打印出ctx的环境参数内容,使用代码:                 Hashtable ht = ctx.getEnvironment();                  Set set = ht.keySet();     Iterator it = set.iterator();                 while(it.hasNext()){                          String ks = (String)it.next();                                  System.out.println( ks + " = " + (String)ht.get(ks) + "<br>");                 }          发现除了java.naming.factory.initial参数不正确外,其它参数都进行了更新,这就说明ctx读取了jndi.properties文件中的内容,my god....,what should i do?          然后我尝试着在 InitialContext ctx = new InitialContext();之后加了一句:               ctx.addToEnvironment("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");      程序仍然不能正常执行,my god,I want to kill myself.         然后我将System.getProperties() 内所有的参数都打印了出错,发现ctx对象取的是它里面的内容,没有办法我只好在         InitialContext ctx = new InitialContext(); 之前加了一句:          System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");   执行程序,good, it is successful.....             但我到现在也没有想明白,到底是为什么ctx的java.naming.factory.initial的参数从jndi.properties文件中读取并更新?            forgot it,it is too defficult for me......                            
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值