Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot undeploy hibernate-entitymanager.jar file

 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a webapp that uses JPA and Hibernate, deploying it on Tomcat. Things are moving along nicely, but I have one ongoing problem that is very frustrating.

Whenever I undeploy my webapp, Tomcat leaves behind the "hibernate-entitymanager.jar" file in the "webapps\myapp\WEB-INF\lib" directory. That means I have to shutdown Tomcat entirely, manually delete the "webapps\myapp" directory and the "work\Catalina\localhost\myapp" directory, then restart Tomcat and FINALLY deploy the new version of my webapp.

The problem is that Tomcat has a lock on the hibernate-entitymanager.jar file. I've set in the "conf\context.xml" file, but that hasn't solved the problem.

Presumably, I'm failing to close something in my code, which is causing the lock, but I can't imagine what.

Here's MyFactory.java, which creates an EntityManagerFactory, as well as EntityManagers:


Here's MyListener.java, which causes MyFactory to create the EntityManagerFactory when the webapp is first deployed, rather than waiting until the users access it:


Somewhere in my web.xml file, a line to cause MyListener to do its thing:


Even if I deploy my webapp, then without ever accessing it, try to undeploy it, Tomcat is still unable to delete hibernate-entitymanager.jar. Why? The MyListener class ran and initalized the EntityManagerFactory, but that's presumably all that has happened. When I tried to undeploy, presumably the EntityManagerFactory's close method was called. Since it never actually called anything else, I can't have forgotten to close something (e.g. a session).

What am I missing?

I'm using Hibernate 3.2, Tomcat 5.5, JDK 1.5, JSF 1.1. Also, in case it matters, I'm using JPA annotations (@Entity, @Table, @Column, etc). I'm using a persistence.xml file and a hibernate.properties file, but no hibernate.cfg.xml file.

Actually, just in case it matters, here's the persistence.xml file:


And here's the hibernate.properties file:


Any ideas?
 
John Shepherd
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this problem as well. It appears that it is a issue for Tomcat running in the windows env. Adding the following to the $TOMCAT_HOME/conf/context.xml fixed the problem.

[ September 25, 2008: Message edited by: John Shepherd ]
 
Gabriele Fabbri
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sincerely want to thank you because I had the same problem and this post solved it!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic