• 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
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Hibernate - close the connection to database correctly at server restart (used in VAADIN)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I'm currently experiencing an interesting problem.

My Situation:
- I am currently developing a web service (I'm using VAADIN for programming with JAVA in eclipse)
- My database behind is java derby
- I am using hibernate
- I'm currently deploying it on Tomcat v7.0

My Problem:
- When I change something in my code (doesn't matter what), the server should reload it without the need of being restarted - I guess that's the overall expected behaviour
- The server reloads the application successfull, but if I try to click on something (so after the reloading) I get an error

Error Message:

Cause: org.hibernate.exception.GenericJDBCException: Could not open connection] with root cause
ERROR XSDB6: Another instance of Derby may have already booted the database C:\HTML-Ausgabe\database\DocumentDB.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
...



My Thoughts on this
It seems that somehow on the reloading process the connection/context to hibernate doesnt get destroyed/closed and so the error occures when the server tries to reconnect to the database

My Code
I have a class, called Hibernate Listener:



My hibernate.cfg.xml:



My (VAADIN) web.xml, in which I added a "listener" for the upper shown HibernateListener (check the text at listener):



I did research, posted also on the hibernate forum (still without even a single answer ) and now did not find a matching thread yet on this website. So I hope I didn't do something wrong.

If anyone of you could help me somehow, I would be really happy. Currently I dont know what to change to stop this error happening. And, of course, I cant always restart the whole server later when my application is on the internet, if I change one line of code.

Thanks a lot for every answer and thought that you're sharing with me.
 
Saloon Keeper
Posts: 22986
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat has a long history of difficulties when it comes to hot-updating stuff that depends on static data such as the ORM base environment. A related issue is its regrettable tendency to leak PermGen space, which really becomes apparent when using ORMs.

Because of this, you are better off using the Tomcat control panel to terminate the old copy of the app, deploy the updated copy, and start it.

Or just do what I do, which is restart Tomcat, which is generally less trouble. Tomcat can restart fairly rapidly in most cases.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic