Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hibernate configure will not read hibernate.cfg.xml file

Posted on 2006-11-16
5
Medium Priority
?
272 Views
Last Modified: 2010-03-31
I have this line of code loading my hibernate.cfg.xml file

SessionFactory sessionFactory = new Configuration().setProperty("hibernate.show_sql", "true").configure("order_mod\\hibernate.cfg.xml").buildSessionFactory();
           
When i run this in my IDE Netbeans it works find however when i tried to run this from the jar file outside of the IDE through the command line java -jar order_mod.jar it gave me an error saying it could not find order_mod\\hibernate.cfg.xml

The directory of my jar file is as follows

Order_Mod.jar
  -order_mod(package)
    -someclass.java
    -someclass_Where_Hibernate_Is_Run_And_Above_Line_Of_Code_Is_Called.java
    -hibernate.cfg.xml
0
Comment
Question by:ethnarch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17960384
try:

SessionFactory sessionFactory = new Configuration().setProperty("hibernate.show_sql", "true").configure("/order_mod/hibernate.cfg.xml").buildSessionFactory();

or

SessionFactory sessionFactory = new Configuration().setProperty("hibernate.show_sql", "true").configure("hibernate.cfg.xml").buildSessionFactory();
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17962096
you should keep the folder containing "order_mod" in the classpath
0
 
LVL 2

Author Comment

by:ethnarch
ID: 17964765
objects-
  That solved my problem thanks

Ajay-
  I don't really understand what you mean if order_mod(the package) is inside my jar, then wouldn't that be inside the classpath?
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17964912
I am asking to keep the folder containing hibernate.cfg.xml (ie. order_mod) on the classpath
0
 
LVL 2

Author Comment

by:ethnarch
ID: 17967006
I still don't get it but nevermind i'll just say this

it is on the classpath according to what i layed out above in the initial question

well thankyou both for helping.
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question