检查你的LocalHome接口的jndi名字是否正确,而且我好像记得Servlet中好像不能使用LocalHome接口,反正我知道在EJB中是可以使用的,它要求必须在一个虚拟机中使用,有时Servlet和EJB的虚拟机不是一个。
解决方案 »
- org.hibernate.PropertyAccessException 各种报错 头大了求解
- flex+java+pureMVC+spring+hibernate
- JDBC连接sqlserver2005报错
- 客户端发送请求,从oracle查出数据导出txt格式提示下载
- 有对配置spring拦截器熟悉的吗?花16元寻找解决
- osworkflow怎么支持ejb,谁有支持ejb的osworkflow.xml配置文件,或解决了jdbc事务的进.(解决另送100分)
- 明明是save,提示的则为update???
- 新建java群19997673
- tomcat安装不上啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- jb7+weblogic+mysql,但jb7老是连不上数据库。,错误如下。。
- xml spy的正式注册码?
- 如何用java把xml和xsl文件合成html文件?
EjbAccountsHome home = (EjbAccountsHome)PortableRemoteObject.narrow(ref, EjbAccountsHome.class);
1.小田甜的方法只适用于调用远程接口。
2.之支吾,上下文属性如下:
private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
String user = null;
String password = null;
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
} return new InitialContext(properties);
}
catch(Exception e) {
System.out.println("Unable to connect to WebLogic server at " + url);
System.out.println("Please make sure that the server is running.");
throw e;
}
}
不知有何不妥,请指教。
试试如此调用:
Context ctx = new InitialContext();
想要使用local interface,那么调用者和EJB必须在同一个jar(ear,zip)里面.
我试过在ejb之间的调用,是成功的。
在同一个包里的原因
在同一个包里的原因
Context initial = new InitialContext();
Object objref = initial.lookup("<your jndi name for EjbAccount>");
return (EjbAccountsHome) objref;