JiveJdon Community Forums
在线379人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » 开源项目大家谈
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 1 回复 / 1
 发表新帖子   回复该主题贴
holyadai

悄悄话
发表文章: 1
注册时间: 2004年11月18日 00:59
hibernate+struts1.1+weblogic8+JBuilder2005的开发环境的配置 2004年11月18日 01:01 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
开发时的环境配置如下:
写一个启动类加载和绑定Hibernate的sessionfactory到weblogic下
代码如下:
public class HibernateStartUp implements T3StartupDef {



public static String CONFIG_FILE_PATH = "/hibernate.cfg.xml";

public void setServices(T3ServicesDef services) {}
public static final String SESSION_FACTORY_JNDI = "hibernate";
public static final String URL = "t3://localhost:7001";
public String startup(String name, Hashtable args) throws Exception {
try {

doBind();
return "Hibernate Startup completed successfully";
} catch (Exception e) {

}
return "Hibernate Startup completed successfully";
}
private static void doBind( ) throws Exception
{
Properties environment = null;
InitialContext context = null;

try
{
environment = new Properties( );
environment.put(

Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
environment.put( Context.PROVIDER_URL, URL );
context = new InitialContext( environment );


Configuration configuration = (new Configuration()).configure(CONFIG_FILE_PATH);
SessionFactory factory = configuration.buildSessionFactory();
if (factory == null)
throw new Exception("SessionFactory cannot be built?!");

try
{
if( context.lookup("hibernate")!= null )
{
context.rebind("hibernate", factory);
}
else
{
context.bind("hibernate", factory);
}
}
catch ( NamingException nameEx )
{
nameEx.printStackTrace();
context.bind("hibernate", factory );
}
}
catch ( NamingException nameExp )
{
throw new Exception( "NamingException: " + nameExp.getMessage( ));
}
catch( Exception excp )
{
throw excp;
}

}

static private InitialContext getInitialContext() throws Exception {
String url = "t3://localhost:7001";

Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,

"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
return new InitialContext(properties);
}
catch(Exception e) {
logger.fatal("Unable to connect to WebLogic server at " + url);
logger.fatal("Please make sure that the server is running.");
throw e;
}
}
}
然后编译
在Jbuilder2005的Configserver下的calsspath下面加入这个类的所在路径,我的是

C:\work\overstock\classes
然后把Hibernate用到的jar文件也加入,就可以开发了。

部署的时候只要把这些路径加入到domain的startWebLogic.cmd中就可以,不过要把

C:\work\overstock\classes中的类打成jar包再加,要不weblogic会找不到的。

参考文章:http://www.hibernate.org/120.html
banq

悄悄话
发表文章: 9484
注册时间: 2002年08月03日 17:08
Re: hibernate+struts1.1+weblogic8+JBuilder2005的开发环境的配置 2004年11月20日 22:50 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
好文章,顶一下表示支持。
这个主题有 1 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  发贴前查询 标签列表勿重复发表问题

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam