一个Hibernate+weblogic的问题
本人用weblogic+hibernate+struts做开发,根据网上的资料做了一个HibernateStartUp类,随着weblogic服务器的启动而加载启动,目的是注册hibernate的SessionFactory.
如果不用上面说的方式,在DAO中做如下处理:
SessionFactory sessionFactory = new Configuration()
.configure()
.buildSessionFactory();
session = sessionFactory.openSession();
可以得到预期的结果,但事实上不可能只有一个DAO,而不可能在每个DAO中都创建SessionFactory实例。
所以我打算还是采用本文一开始提到的方式,这样就需在startWeblogic.cmd中设置HibernateStartUp的classpath,如是我做了如下修改:
@REM Set HibernateStartUp classpath
set Hibernate_StartUp=D:\SunJava\bea\user_projects\domains\mydomain\applications\bookonl
ine\WEB-INF\classes
set Hibernate_lib=D:\SunJava\bea\user_projects\domains\mydomain\applications\bookonline\
WEB-INF\lib
set CLASSPATH=%Hibernate_StartUp%;%Hibernate_lib%;%CLASSPATH%
(同时我也参阅了一些有关classLoader的文章(AppServer classLoader,ejb classLoader,web classLoader),自认为做了如上设置应该不会有什么问题了),但是事与愿违,还是出错了,如下:)
<2006-4-3 下午06时22分36秒 CST> <Info> <HTTP> <BEA-101047> <[ServletContext(id=11858882,name=wl_management_internal1,context-path=/wl_m
anagement_internal1)] WebServiceServlet: init>
<2006-4-3 下午06时22分36秒 CST> <Info> <Deployer> <BEA-149059> <Module wl_management_internal2 of application wl_management_internal2 i
s transitioning from prepared to active on server myserver.>
<2006-4-3 下午06时22分36秒 CST> <Info> <Deployer> <BEA-149060> <Module wl_management_internal2 of application wl_management_internal2 s
uccessfully transitioned from prepared to active on server myserver.>
<2006-4-3 下午06时22分36秒 CST> <Info> <HTTP> <BEA-101047> <[ServletContext(id=12354531,name=wl_management_internal2,context-path=/wl_m
anagement_internal2)] WebServiceServlet: init>
<2006-4-3 下午06时22分36秒 CST> <Info> <Deployer> <BEA-149208> <Initialization Complete.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JTA> <BEA-110441> <Opening transaction log with driver version "j1.0" and synchronous write pol
icy "Cache-Flush". For information on synchronous write policies, refer to the weblogic.management.configuration.ServerMBean javadoc or
console online help.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JDBC> <BEA-001138> <Resuming the JDBC service.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JDBC> <BEA-001140> <Resume complete.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JMS> <BEA-040108> <User connection factory "DefaultXAConnectionFactory" is started.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JMS> <BEA-040108> <User connection factory "QueueConnectionFactory" is started.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JMS> <BEA-040108> <User connection factory "MessageDrivenBeanConnectionFactory" is started.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JMS> <BEA-040108> <User connection factory "DefaultConnectionFactory" is started.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JMS> <BEA-040108> <User connection factory "TopicConnectionFactory" is started.>
<2006-4-3 下午06时22分37秒 CST> <Info> <JMS> <BEA-040306> <JMS service is active now.>
<2006-4-3 下午06时22分37秒 CST> <Info> <HTTP> <BEA-101129> <Initializing the Web application container.>
<2006-4-3 下午06时22分37秒 CST> <Info> <HTTP> <BEA-101238> <HTTP log rotation is size based for the Web server: myserver.>