该帖已经被评为精华帖
|
|
---|---|
作者 | 正文 |
发表时间:2004-01-07
我试了一下,完全是OK的。但为什么大家都不用这个办法,而是想在 struts plugin 或者 filter 中来初始化一个 SessionFactory 呢?
设置办法: <hibernate-configuration> <SessionFactory name="HibernateSessionFactory2"> ======================== ........ 使用时与手动 bind 一样。 SessionFactory sf = ctx.lookup("HibernateSessionFactory2"); 只是不知道怎么样 close 掉它。没有看到文档中哪里有说明,我估计应该不需要手动去管它。 |
|
返回顶楼 | |
发表时间:2004-01-08
呵呵,我会试试的
|
|
返回顶楼 | |
发表时间:2004-01-10
我测试你的代码,怎么老是出现问题啊、我是采用你说的那种用plugin-jidi的方式,代码也是用的你的,访问TestServlet的时候老是出错,我感觉jndi就没有被绑定错误代码如下:
004-1-10 10:13:10 org.apache.commons.modeler.Registry loadRegistry 信息: Loading registry information 2004-1-10 10:13:11 org.apache.commons.modeler.Registry getRegistry 信息: Creating new Registry instance 2004-1-10 10:13:12 org.apache.commons.modeler.Registry getServer 信息: Creating MBeanServer 2004-1-10 10:13:15 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on port 8080 Starting service Tomcat-Standalone Apache Tomcat/4.1.18 2004-1-10 10:14:10 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on port 8080 2004-1-10 10:14:10 org.apache.jk.common.ChannelSocket init 信息: JK2: ajp13 listening on /0.0.0.0:8009 2004-1-10 10:14:10 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=30/261 config=D:\develope\Tomcat41\conf\jk2.properties net.sf.hibernate.HibernateException: Exception geting SessionFactory from JNDI at com.huangdong.demo.util.HibernateUtilPlus.currentSession(HibernateUtilPlus.java:30) at com.huangdong.demo.bean.TestHibernate.TestAddPlus(TestHibernate.java:45) at com.huangdong.demo.servlet.TestServlet.doGet(TestServlet.java:72) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530) at java.lang.Thread.run(Thread.java:536) |
|
返回顶楼 | |
发表时间:2004-01-10
代码是一样的吗?你的初始化信息中tomcat并没有加载struts的plugin的初始化呀
|
|
返回顶楼 | |
发表时间:2004-01-16
我也是通过Struts plugin的方式完成hibernate的sessionFactory的初始化,
但我的tomcat窗口的信息很简单,根本就没有关于加载Struts Plugin方面的信息,但确实是加载成功了,不知道为什么. |
|
返回顶楼 | |