facebook

hibernate session factory class not working

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #302191 Reply

    I used the hibernate new session factory class generated, and it’s not working. I have these two calls:

    MMHibernateSessionFactoryAnnotations.setConfigFile(PostEC.hibernatePropertiesFilePath);
                Session theSess = MMHibernateSessionFactoryAnnotations.getSession();

    which result in the app just exiting; no output, no debug, nothing. Just dies. I am definitely getting a valid path to a hibernate.cfg.xml file from PostEC.hibernatePropertsFilePath so it should be setting the path, then the next line should cause it to create a new session factory with the right properties. That isn’t happening, and I’d like to know why. Thanks.

    Bill

    #302193 Reply

    It looks to me that you have to have the configuration file, hibernate.cfg.xml in your classpath. Period. I removed mine from there, and I get this output, where I have a valid hibernate.cfg.xml file on my file system at /

    The factory thinks the hibernate config file is at: /hibernate.cfg.xml
    Sep 08 04:33:14 (Configuration.java:1426) INFO org.hibernate.cfg.Configuration – configuring from resource: /hibernate.cfg.xml
    Sep 08 04:33:14 (Configuration.java:1403) INFO org.hibernate.cfg.Configuration – Configuration resource: /hibernate.cfg.xml
    %%%% Error Creating SessionFactory %%%%
    org.hibernate.HibernateException: /hibernate.cfg.xml not found
    at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
    at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
    at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:972)
    at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:69)
    at com.medialets.Ingest.MMHibernateSessionFactoryAnnotations.<clinit>(MMHibernateSessionFactoryAnnotations.java:41)
    at com.medialets.service.PostEC.<init>(PostEC.java:159)
    at com.medialets.service.PostEC.main(PostEC.java:127)

    Why doesn’t this simple thing work? Why do I absolutely have to have this configuration file on my classpath in order for hibernate to not blow up? I cannot believe that this would be such a difficult thing? Surely, somebody else has need to load the configuration file from someplace else other than within their app? HIbernate and Java == faiil

    #302239 Reply

    wkhatch,
    Can you give some more information?
    1. What are your installation details? You can get them from MyEclipse > Installation Summary > Installation Details.
    2. What is the version of hibernate that you are using?
    3.

    PostEC.hibernatePropertiesFilePath

    Is this a custom class that you created?
    Can you verify if the path returned in the above statement is a valid path of your config file?
    4.

    MMHibernateSessionFactoryAnnotations

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: hibernate session factory class not working

You must be logged in to post in the forum log in