cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in placing hibernate.cfg.xml

Former Member
0 Kudos

Hi,

I have written one ejb project with hibernate in my net weaver.Now i have a problem in placing hibernate.cfg.xml.so tell me where to place it .Give some examples related to that and some related links.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

you can place it into the root of the EJB project as your EJBs probably access Hibernate as persistence layer. In this case make sure that you pass the string "hibernate.cfg.xml" within the method invocation when retrieving a SessionFactory as follows:


try
{
Configuration cfg = new Configuration();
sessionFactory = cfg.configure  
     ("hibernate.cfg.xml").buildSessionFactory();
}
catch (Throwable ex)
{
...	
}

Otherwise the Configuration file may not be found by the application class loader due to different path syntax.

For further information you can refer to this https://www.sdn.sap.com/irj/sdn/developerareas/java?rid=/webcontent/uuid/e081a4b6-0801-0010-7fa4-c3c... [original link is broken] [original link is broken], although the hibernate.cfg.xml file is placed in the Web-Project in this example.

Hope this helps,

Best regards,

Robin