D
Daniel
Hi all.
Currently, I have Hibernate working in an exploded directory.
I am having a problem setting up Hibernate's configuration when it is
wrapped up in a war file. The problem, I believe, is somewhere in
setting up the Configuration object. Can you send me or post some code
that shows me how to get the hibernate.cfg.xml file from the WAR and
how you configured Configuration?
I tried getClass().getResourceAsStream( path ) and then converted that
stream into a String, and tried Configuration.configure( string ). It
found the file and I printed it out the contents of that string to make
sure and I do see the hibernate.cfg.xml contents.
I put the war in Tomcat 5's webapp dir and got the following during
startup:
"net.sf.hibernate.HibernateException: (The contents of my
hibernate.cfg.xml go here) not found"
Second related question, when developing I would prefer to use the
exploded directory format, so would I have to have one code for getting
the config from the war file and one code for getting it from a
java.io.File, and then comment one of those codes out depending if I am
developing or want to test it as a war file?
Much appreciated and thanks in advance.
Currently, I have Hibernate working in an exploded directory.
I am having a problem setting up Hibernate's configuration when it is
wrapped up in a war file. The problem, I believe, is somewhere in
setting up the Configuration object. Can you send me or post some code
that shows me how to get the hibernate.cfg.xml file from the WAR and
how you configured Configuration?
I tried getClass().getResourceAsStream( path ) and then converted that
stream into a String, and tried Configuration.configure( string ). It
found the file and I printed it out the contents of that string to make
sure and I do see the hibernate.cfg.xml contents.
I put the war in Tomcat 5's webapp dir and got the following during
startup:
"net.sf.hibernate.HibernateException: (The contents of my
hibernate.cfg.xml go here) not found"
Second related question, when developing I would prefer to use the
exploded directory format, so would I have to have one code for getting
the config from the war file and one code for getting it from a
java.io.File, and then comment one of those codes out depending if I am
developing or want to test it as a war file?
Much appreciated and thanks in advance.