我的 server.xml 是 这样写的 :   <GlobalNamingResources>
    <Environment
      name="simpleValue"
      type="java.lang.Integer"
      value="30"/>
    <Resource
      auth="Container"
      description="User database that can be updated and saved"
      name="UserDatabase"
      type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
   <Resource
      name="jdbc/REPORTDS"
      type="javax.sql.DataSource"
      password="dasc"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      maxIdle="2"
      maxWait="5000"
      validationQuery="select * from dual"
      username="dasc_753_ps"
      url="jdbc:oracle:thin:@10.1.3.105:1521:ora9i"
      maxActive="4"/> 
  </GlobalNamingResources>
web.xml  
    <resource-ref>
       <description>DB Connection</description>
       <res-ref-name>REPORTDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
    </resource-ref>
   

解决方案 »

  1.   

    调用 HibernateSessionFactory  的 currentSession() 方法处 总是  在  执行下面 代码 报  工厂未 绑定异常...
     sessionFactory = (SessionFactory) ctx.lookup("java:comp/env/hibernate/SessionFactory");
      

  2.   

    web应用 启动会 运行 我的 这个 类  package com.aspire.reportSystem.common.dao;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;
    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;public class HibernateInit
        implements ServletContextListener {
      public void contextDestroyed(ServletContextEvent servletContextEvent) {
      }
      
      private static SessionFactory sf;
      
      public static SessionFactory getSessionFactory() {
          return sf;
      }
      public void contextInitialized(ServletContextEvent servletContextEvent) {
        try {
          Configuration conf = new Configuration().configure();
          
          sf = conf.buildSessionFactory();
          
          System.out.println("SessionFactory =   " + sf);
          
        }
        catch (Exception e) {
          e.printStackTrace();
        }
      }
    }这块的 sf = conf.buildSessionFactory(); 是没问题的,就差 绑定 session工厂啦  ,快 帮帮忙撒 ~oo~
      

  3.   

    不报 绑定工厂错误了,报 这个 错误 ...  javax.naming.NamingException: Could not create resource factory instance [Root e
    xception is java.lang.InstantiationException: org.hibernate.SessionFactory]
            at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceF
    actory.java:102)
            at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:3
    04)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
            at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
            at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
            at javax.naming.InitialContext.lookup(InitialContext.java:351)
            at com.aspire.reportSystem.common.dao.HibernateSessionFactory.currentSes
    sion(HibernateSessionFactory.java:59)
            at com.aspire.reportSystem.common.dao.DBdao.queryTable(DBdao.java:30)
            at com.aspire.reportSystem.portal.report.htmlReport.ReportPageComponent.
    getParaDetailVO(ReportPageComponent.java:405)
            at com.aspire.reportSystem.portal.report.htmlReport.ReportPageComponent.
    getQueryPara_ByType(ReportPageComponent.java:250)
      

  4.   

    tomcat的不同版本配置是有区别的,好像还要在D:\apache-tomcat-5.5.16\conf\Catalina\localhost下面加一个项目同名的xml文件,具体的就不是很记得了,可以在网上找找。
      

  5.   

    D:\apache-tomcat-5.5.16\conf\Catalina\localhost  下面的配置文件我早 写啦 ,不是那的问题,谁 有没有 现成 的 配置好的 相关 博客  或者 文档什么的 ?  发给我一份 , 类似 我现在的 想法 配的 , 多谢了
      

  6.   

    你的Hibernate配置文件中的java:comp/env/REPORTDS
    应该改成
    java:comp/env/jdbc/REPORTDS
    关于配置工厂到JNDI:
    在  <GlobalNamingResources>
          ………………
      </GlobalNamingResources>
    中添加一个
        <Resource
          auth="Container"
          name="hibernate/SessionFactory"
          type="com.aspire.reportSystem.common.dao.HibernateSessionFactory"
          factory="这里添创建这个类工厂类的工厂类,这个类必须实现了javax.naming.spi.ObjectFactory接口"/>
    然后在Web.xml中添加:
     <resource-ref>
           <description>sessionFactory</description>
           <res-ref-name>hibernate/SessionFactory</res-ref-name>
           <res-type>com.aspire.reportSystem.common.dao.HibernateSessionFactory</res-type>
           <res-auth>Container</res-auth>
        </resource-ref>
    你工厂类和创建工厂类的类JAR包应该放到Tomcat的lib目录下。
    大致就是这么一个流程,祝你好运,有什么问题再说。