I'm running on Win 7 using Eclipse 4.2 starting a web app on a Tomcat 7 server and using Derby database. I have tried many approaches but run consistently into a common problem:
- Everything works just fine the first time I start up and run.
- When I redeploy my application after a change, all database connections hang (any kind of restart).
- If I stop Eclipse and restart Eclipse, that clears up the problem and the next run works fine again.
Having done some investigation, it appears that the problem is that the Derby port (1527) is not released from one execution of the server to the next. That seems very strange to me since Derby is started by the Tomcat instance which is a separate javaw process.
I've tried:
- Configuring the Derby connection as a Tomcat resource
- Establishing the connection within my code (rather than via Tomcat resource)
- Both the embedded and the network driver
- Starting / stopping the network driver from a servlet on startup and shutdown of the Tomcat server
- Shutting down the embedded driver via servlet on shutdown of Tomcat
Again, every approach works fine to connect the first time.
One other symptom that doesn't appear to be related (except for as a possible indicator of whether or not shutdown completes correctly) is that the db.lck file for my database never gets deleted. However, whether or not it exists has no bearing on whether or not I can reconnect (only stopping/starting eclipse has an impact).
Any insight would be appreciated. Thanks!