| 发表于:2007-06-19 13:49:40 楼主 |
非ejb环境,我想实现petstore中的那种通过jndi查找bean来实现model层的做法。根据目前网上找到的方法: 在web.xml中加入: <env-entry> <description> this is a testing for jndi invoking </description> <env-entry-name> jnditst </env-entry-name> <env-entry-value> com.strutsweb.login.web.jnditest </env-entry-value> <env-entry-type> java.lang.string </env-entry-type> </env-entry> 启动后servers的jndi tree中找不到配置好的这个jndi实例,应用中调用: properties p = new properties(); p.put(context.initial_context_factory, "weblogic.jndi.wlinitialcontextfactory "); p.put(context.provider_url, "t3://localhost:7001 "); initialcontext ic = new initialcontext(p); string classname = "jnditst "; jnditest test = (jnditest)ic.lookup(classname); test .printhello(); 抛出异常: javax.naming.namenotfoundexception: unable to resolve 'jnditst '. resolved ' '; remaining name 'jnditst ' at weblogic.jndi.internal.basicnamingnode.newnamenotfoundexception(basicnamingnode.java:1123) at weblogic.jndi.internal.basicnamingnode.lookuphere(basicnamingnode.java:250) at weblogic.jndi.internal.servernamingnode.lookuphere(servernamingnode.java:171) at weblogic.jndi.internal.basicnamingnode.lookup(basicnamingnode.java:204) at weblogic.jndi.internal.wleventcontextimpl.lookup(wleventcontextimpl.java:267) 请教各位这个问题该如何解决,如果说方法本身有误的话,正确的应该如何处理? 不胜感激! |
|
|
|
|