hibernate.cfg.xml放在classes目录下

解决方案 »

  1.   

    为什么这样做呢?
    如果不做分布没必要用ejb
    直接struts+hibernate不就好了?
      

  2.   

    在这里sessionBean是用来处理业务逻辑的
      

  3.   

    打包在CLASSES\META-INF目录应该可以.
      

  4.   

    你是怎么写configure代码的?贴来看看?
      

  5.   

    SessionBean中:
    package com.beststar.sjrkxt.ejb.sb;
    public void Hello(){
    try {
    _RootDAO.initialize("/hibernate.cfg.xml");
    } catch (HibernateException e) {
    // TODO 自动生成 catch 块
    e.printStackTrace();
    }
    }
    RootDAO中:
    package com.beststar.sjrkxt.hbnt.base; public static void initialize (String configFileName) throws HibernateException {
    if (null == configFileName && sessionFactoryMap.size() > 0) return;
    else if (null != sessionFactoryMap.get(configFileName)) return;
    else {
    Configuration cfg = new Configuration();
    if (null == configFileName)
    cfg.configure();
    else
    cfg.configure(configFileName);
    setSessionFactory(configFileName, cfg.buildSessionFactory());
    }
    }
      

  6.   

    protected static void setSessionFactory (String configFileName, SessionFactory sessionFactory) {
    sessionFactoryMap.put(configFileName, sessionFactory);
    }
      

  7.   

    代码为插件自动生成,不会有问题的,在web项目下正常啊,怎么放到EJB项目中就不行了呢?
      

  8.   

    你把Hibernate的所有类打成jar包,作为资源加到EJB项目中,就可以了。引用他人的一段话:
    Look, this guy gets troubles. It is the Hibernate's problem.You can try this, all your hibernate classes are saved in one URL, and make a resource refered by the EJB. Inside the EJB you code JNDI look up the URL and download the class for local use. I don't think this is J2EE project if you play Hibernate. 
      

  9.   

    hibernate放在服务器的classpath中