7 Replies Latest reply on Jul 11, 2012 1:55 AM by jaikiran pai

    jboss-as-7.0.2.Final - /hibernate.cfg.xml not found

    Srikrishna Kalavacharla Newbie

      Hi,

      We have a REST application working fine in jboss-6.0.0.Final which we want to migrate to jboss-as-7.0.2.  When I deploy the war file to jboss-as-7.0.2 it gives me an error saying "Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found".  hibernate.cfg.xml file is located in WEB-INF/classes/ folder.  I tried moving the file around (WEB-INF/ folder, WEB-INF/lib/ folder, root folder (/)) but no luck.  Project is setup as a "Dynamic Web Project" in Eclipse and I use jboss tools to generate the war file.  Directory structure is as follows and nothing fancy.  

       

      Example.war - 
          META-INF
              MANIFEST.MF
          WEB-INF
              classes
                  hibernate.cfg.xml
                  example-infinispan.xml
                  com/*               
              lib
              web.xml 
      
      

       

      When I create SessionFactory instance, I do the following:

       

      sessionFactory = new Configuration().configure().buildSessionFactory();
      

       

      To test it out, if I try to load hibernate.cfg.xml from an external path (Ex: jboss-as-7.0.2.Final/hibernate/hibernate.cfg.xml), jboss-as-7.0.2 finds hibernate.cfg.xml file, but the same problem arises when it's trying to load all the *.hbm.xml files defined in hibernate.cfg.xml file. 

       

      String hibernateConfigFilePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "hibernate" + System.getProperty("file.separator") + "hibernate.cfg.xml";
      Configuration configuration = new Configuration();
      configuration.configure(new File(hibernateConfigFilePath));
      sessionFactory = configuration.buildSessionFactory();
      

       

       

      One more important detail here is, I get the same error in both modes (domain & standalone) even though my focus is to make this work in domain mode.

       

      Thoughts? 

       

      Thanks

      Srikrishna Kalavacharla