context没有初始化好,你用的应用服务器是什么的?
解决方案 »
- 求算法 打印菱形三角
- 怎样用JButton给JTable 交互添加行
- 一个超级难的字符串解析!!!!!
- Java中ResultSet对象有没有方法直接得到一条记录的列数
- 恳请您伸出援助之手!帮帮小弟!SAX解析XML问题
- 如何让JAVA程序在不同语言的操作系统中自动选择所使用的语言
- 有哪位高人知道如何改ShowMessageDialog中显示的字体?急!!
- 菜鸟我用j2sdk1.4.1 和 JCreator 不知如何查阅java的库,听说在sun网站上有,不知有没有离线版?
- 怎样建java环境?
- 小白求解 韩顺平老师教程里坦克大战的爆炸效果为什么是从第二个坦克爆炸才有
- 高分求救,如何做个招聘网站
- 问一个很菜的问题(100分,高手阿,你在哪里?)
是不是我的JNDI的命名没在System.getProperties里呢,还是要找WEBLOGIC的。象这样
private AccountHome lookupHome()
throws NamingException
{
Context ctx = getInitialContext();
try {
Object home = ctx.lookup("beanManaged.AccountHome");
return (AccountHome) PortableRemoteObject.narrow(home, AccountHome.class);
} catch (NamingException ne) {
log("The client was unable to lookup the EJBHome. Please make sure " +
"that you have deployed the ejb with the JNDI name " +
"beanManaged.AccountHome on the WebLogic server at "+url);
throw ne;
}
}
/**
* Get an initial context into the JNDI tree.
*
* Java2 clients can use the jndi.properties file to set the
* INITIAL_CONTEXT_FACTORY and the PROVIDER_URL
* private Context getInitialContext() throws NamingException {
* return new InitialContext();
* }
*
*
* Using a Properties object will work on JDK 1.1.x and Java2
* clients
*/
private Context getInitialContext() throws NamingException {
try {
// Get an InitialContext
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, url);
return new InitialContext(h);
} catch (NamingException ne) {
log("We were unable to get a connection to the WebLogic server at "+url);
log("Please make sure that the server is running.");
throw ne;
}
}
private String url;
private AccountHome home;
public Client(String url)
throws NamingException
{
this.url = url;
home = lookupHome();
} String url = "t3://localhost:7001";
按你说的做拉,还是有问题啊,
javax.naming.NameNotFoundException: Unable to resolve h. Resolved: '' Unresolved:'h' ; remaining name '' at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:85) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:253) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:220) at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35) at $Proxy0.lookup(Unknown Source) at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323) at javax.naming.InitialContext.lookup(InitialContext.java:350) at test.hClient.main(hClient.java:43)Exception in thread "main"
我的是这么写的Object obj = ctx.lookup("hHome");而且在WEB下,EJB的图标和叙述都很正常