سؤال

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!

هل كانت مفيدة؟

المحلول 2

I did finally figure this out. It turns out I had the derby jars in the Tomcat lib folder (for Tomcat) and in the deployment assembly for my application in Eclipse (rather than just in the build path). So Tomcat was using the built-in libs, while my app was using the embedded libs, and this resulted in conflicts. Leaving the libs as part of Tomcat and removing them from my war file solved the problem completely.

نصائح أخرى

After some further investigation I'm going to call this a duplicate of: Cannot create JDBC driver of class ' ' for connect URL 'null' : I do not understand this exception. It's not quite the same thing, but that solution (creating META-INF/context.xml) allows it to proceed to failing calls rather than hangs, which is a significant improvement and suggests it's largely related.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top