Hibernate version: 3.0.3
Name and version of the database you are using: Oracle 9.2.0.7
I have an interesting problem on my hands. I've read through the docs and the forums, and understand that what I'm trying to do may not quite be possible in the manner in which I'm seeking, but I figured I'd solicit help and opinions first.
What I'm facing is this: I have Jetspeed portlet application running in a Tomcat web container using Hibernate. This application runs fine, and works as would be expected with hibernate. What I need to do is have a class that is part of the root package strucuture, but separate from the running thread of tomcat. In other words, I need to have the instance of tomcat running my portal application using hibernate, and then run a command line batch of a java program (with a main() method) that will make use of the existing hibernate structures in the portal application.
Currently, the issues I'm having is that when running the java app from the command line, I get an error saying that hibernate cannot find my configuration files (/hibernate.properties and /hibernate.cfg.xml). I'm using the same Hibernate Utility class to generate a session factory that I use within my portal that calls the configuration.configure().buildSessionFactory(); methodology to get a session factory instance in the static portion of the Hibernate utility class. The error subequently gets thrown from the ClassLoader.getSystemResourceAsStream(name) method because it cannot find the hibernate.cfg.xml file.
I know this error is thrown when hibernate cannot locate the resource in question based on the classpath root (my libraries are in WEB-INF/lib and the configuration files are in WEB-INF/classes, which works fine for tomcat). What my question is, is can I "fool" hibernate into using a session factory instance from the tomcat context, or will I have to completely separate out these files I'm writing into thier own "mini" hibernate package where I can put a specialized hibernate.cfg.xml mapping file in the same context as the localized classpath root and compile them separately from my portal application?
It would be much nicer if I could just use the existing Vo and DAO classes I have for the portal application inside the batch java application so I won't have duplicate sources to maintain (as well as a separate application that will be doing basically the same thing as part of the portal).
Thanks in advance for any help and/or insight you can provide.
|