About loading of hibernate configuration in HibernateHelper.
quepasa Oct 18, 2007 3:57 AMFirst, i want to sorry for my very intermediate english :)
So... in jBPM config-file (jbpm.cfg.xml) exists a string
when i try to execute this code
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); try { jbpmContext.deployProcessDefinition(processDefinition); } finally { jbpmContext.close(); }
there exception throws with message Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found.
now see the full stack trace:
Exception in thread "main" 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.jbpm.db.hibernate.HibernateHelper.createConfiguration(HibernateHelper.java:91) at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration(DbPersistenceServiceFactory.java:69) at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91) at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:95) at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:99) at org.jbpm.persistence.db.DbPersistenceService.getGraphSession(DbPersistenceService.java:341) at org.jbpm.JbpmContext.getGraphSession(JbpmContext.java:571) at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:173) at ru.emd.escom3.core.CoreTest.main(CoreTest.java:52)
and the cause of this exception is that the HibernateHelper.java trying to use specified hibernate's config-file like a resource in the class path. Look here:
public abstract class HibernateHelper { ... public static Configuration createConfiguration(String cfgXmlResource, String propertiesResource) { .... // if a special hibernate configuration xml file is specified, if (cfgXmlResource!=null) { // use the configured file name log.debug("creating hibernate configuration resource '"+cfgXmlResource+"'"); configuration.configure(cfgXmlResource); } else { log.debug("using default hibernate configuration resource (hibernate.cfg.xml)"); configuration.configure(); } .... } }
here we can see, that
configuration.configure(cfgXmlResource);is called when config-file is a xml-file (it's my case).
And the configuration is the instance of Configuration class (it is in hibernate source code), and method configure() of this class trying to load transmitted file-name like a resource.
BUT MY hibernate.cfg.xml IS NOT A RESOURCE.
It is an ordinary file on file system, and i have a question: how to use such hibernate's config-file in this case ?