在线410人
首页
主题表
培训咨询
标签
精华
查搜
注册
登陆
用户
自动登陆
密码
新用户注册
忘记密码?
首页
»
论坛
»
J2EE/JavaEE/JEE/EJB/JSF等技术讨论
上一主题
我把以前的一个用JDBC的系统用hibernate改写了部分模块,这样是否会有问题 谢谢
返回本主题
返回主题列表
下一主题
安装petStore后,基本运行正常,操作pointBase中的数据正常。 但是petStore管理员的Rich Client却无法在JAVA Web Start 中显示。(JAVA Web ..
Go
总共有
0
回复 /
1
页
前往下页:
chenkl
悄悄话
发表文章: 20
注册时间: 2003年08月25日 10:33
struts1.1+weblogic7.0+hibernate2.02的问题
2003年08月25日 10:44
标签列表
我将SessionFactory bind到wls的jndi树上,在web层(struts的plugin中)可以lookup到,但在
EJB
层却loopup 不到,我的代码如下:
//将 SessionFactory绑定到wls的jndi上
private static void initSessionFactory() throws
Hibernate
Exception{
SessionFactory sf = new Configuration().configure().buildSessionFactory();
try {
if (context == null) {
context = getInitialContext();
}
context.bind(GlobalNames.SESSION_FACTORY, sf);
}
catch (NamingException ex) {
System.out.println("init SessionFactory failed! ");
}
}
//这个方法使用weblogic的datasource,来返回session
public static Session getSession() throws
Hibernate
Exception {
Connection conn = null;
SessionFactory factory = null;
try {
conn = DBUtil.getConnection();
}
catch (NoConnectionException ex) {
}
try {
if (context == null) {
context = getInitialContext();
}
factory = (SessionFactory) context.lookup(GlobalNames.SESSION_FACTORY);
}
catch (NamingException ex1) {
}
if(factory == null)
System.out.println("Can't lookup SessionFactory form jndi tree");
Session session = factory.openSession(conn);
return session;
}
//在
Struts
的plugin中用上述的getSession方法是可以lookup到的,也可以返回session
private void initSF() {
NJSSSF sf = new NJSSSF();
try {
sf.init();
Session s1 = sf.getSession();
System.out.println("get session from plugin :(1)- " + s1.toString());
s1.close();
}
catch (HibernateException ex) {
if(GlobalNames.DEBUG_OUTPUT_FLAG){
System.out.println(ex.toString());
}
}
}
但在
EJB
层用getSession()方法却找不到绑定在wls jndi 上的SessionFactory,但却可以lookup到
EJB
,请高手指教?
这个主题有
0
回复 /
1
页
Go
上一主题
返回本主题
返回主题列表
返回页首
下一主题
热点TAG:
AOP
cache
缓存
DDD
EJB
集群
设计模式
Hibernate
IOC
JiveJdon
OO
RBAC
Seam
Spring
Struts
正在读取,请等待...
Wowzio
grab this
·
technology
blog
查询本论坛内
近一天
近三天
近一周
近一月
近三月
近半年
近一年
所有
回复超过
的热门帖子
标题
内容
每2分种自动备份发贴内容Ctrl-V粘贴取出,提问题前先查询
标签列表
解惑之道在
J道
,打造中国最具影响力的的企业软件社区
OpenSource
JIVEJDON
v3.0
Powered by
JdonFramework
Code © 2002-08
jdon.com
anti spam