Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Cannot undeploy hibernate-entitymanager.jar file

 
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?
 
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 ]
 
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!
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic