Results 1 to 3 of 3
  1. #1
    splatter is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default How to let hibernate know where to look for configuration file

    I just export my java project to executable jar. I have somehow made my project work to access value from DB (hibernate.cfg.xml), config.properties, and log4j.properties & editable for future...

    I want to put hibernate.cf.xml, config.properties and log4j.properties in the outside of jar and place them somewhere in other directory (/mon/properties)...

    when I run my jar
    Java Code:
    java -cp coreservice.jar:/mon/properties id.co.bni.coreservice.controller.CoreServiceController
    but, I got this error
    Java Code:
    Could not find or load main class
    any help will be pleasure :)

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,904
    Rep Power
    5

    Default Re: How to let hibernate know where to look for configuration file

    You do it like you are attempting to do now. So now you only have to solve the actual problem that you are having, Java not finding the main class, and you'll be set.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    splatter is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default Re: How to let hibernate know where to look for configuration file

    Quote Originally Posted by gimbal2 View Post
    You do it like you are attempting to do now. So now you only have to solve the actual problem that you are having, Java not finding the main class, and you'll be set.
    I just remember by now that this separator ":" just for unix and for windows use this ";"...
    I am windows user

    so I modify my command
    Java Code:
    java -cp coreservice.jar;/mon/properties id.co.bni.coreservice.controller.CoreServiceController
    now I got this error
    Java Code:
    log4j:WARN No appenders could be found for logger (org.hibernate.type.BasicTypeRegistry).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found
    Exception in thread "main" java.lang.ExceptionInInitializerError 
            at id.co.bni.coreservice.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:19)
            at id.co.bni.coreservice.persistence.HibernateUtil.<clinit>(HibernateUtil.java:7)
            at id.co.bni.coreservice.controller.CoreServiceController.LoadData(CoreServiceController.java:28)
            at id.co.bni.coreservice.controller.CoreServiceController.main(CoreServiceController.java:229) Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
            at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
            at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2146)
            at org.hibernate.cfg.Configuration.configure(Configuration.java:2127)
            at org.hibernate.cfg.Configuration.configure(Configuration.java:2107)
            at id.co.bni.coreservice.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:11)
            ... 3 more
    the command still not direct hibernate to look my folder (/mon/properties) for configuration....
    Last edited by splatter; 10-23-2013 at 09:48 AM.

Similar Threads

  1. Replies: 3
    Last Post: 08-30-2012, 06:24 PM
  2. Could not parse configuration: /hibernate.cfg.xml
    By Matang in forum Web Frameworks
    Replies: 2
    Last Post: 04-10-2011, 02:28 PM
  3. Create a launch configuration file
    By juza in forum Eclipse
    Replies: 0
    Last Post: 03-24-2010, 12:55 PM
  4. Replies: 0
    Last Post: 03-29-2008, 12:44 PM
  5. Replies: 0
    Last Post: 09-26-2007, 08:35 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •