import java.util.Properties;
import javax.naming.*;public class Jndi {
public static void main(String ar[]) {
Context ctx = null;
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
try { ctx = new InitialContext(p);
String test = "JNDI Test example";
ctx.bind("name", test);
String s = (String) ctx.lookup("name");
System.out.println(s);
String str = "welcome to you";
ctx.rebind("name", str);
s = (String) ctx.lookup("name");
System.out.println(s);
} catch (NamingException e) {
System.out.println(e.toString());
}
}
}Exception in thread "main" java.lang.IllegalArgumentException: Context: object to bind must be Remote, Reference, or Referenceable
at weblogic.jrmp.Context.encodeObject(Context.java:375)
at weblogic.jrmp.Context.bind(Context.java:83)
at weblogic.jrmp.Context.bind(Context.java:94)
at javax.naming.InitialContext.bind(Unknown Source)
请问有人知道为什么吗????
import javax.naming.*;public class Jndi {
public static void main(String ar[]) {
Context ctx = null;
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, "t3://localhost:7001");
try { ctx = new InitialContext(p);
String test = "JNDI Test example";
ctx.bind("name", test);
String s = (String) ctx.lookup("name");
System.out.println(s);
String str = "welcome to you";
ctx.rebind("name", str);
s = (String) ctx.lookup("name");
System.out.println(s);
} catch (NamingException e) {
System.out.println(e.toString());
}
}
}Exception in thread "main" java.lang.IllegalArgumentException: Context: object to bind must be Remote, Reference, or Referenceable
at weblogic.jrmp.Context.encodeObject(Context.java:375)
at weblogic.jrmp.Context.bind(Context.java:83)
at weblogic.jrmp.Context.bind(Context.java:94)
at javax.naming.InitialContext.bind(Unknown Source)
请问有人知道为什么吗????
解决方案 »
- 各路大侠帮忙解决一个算法问题
- 找不到spring配置文件
- resin-3.0.27运行SSH报NoSuchMethodError:.PersistenceContext .properties
- 无刷新技术问题
- 电脑和用户名如何邦定
- 向各位高手请教: 如何在JAVA中定义自己的字符集?
- 我对数据库进行操作的时候发生的错误,解决不了,请高手指教
- 寻求方案“Web实时对话”
- 设置自己的classloader的问题
- 怎样设置xml中<Order pono="PO0626-003237">的pono="PO0626-003237">的属性
- c:url路径问题,高手指教
- spring配置c3p0连接池后出现问题
你可以看看这个例子,这个例子能体现出你出错的原因http://hi.baidu.com/pengfeiiw/blog/item/b203893f719bf7ea54e723fb.html