title: Best practice? JNDI, Hibernate and Tomcat
body: <p>I've got a web application, hosted with tomcat, which uses hibernate to talk to a database.</p>
  
  <p>I'm looking at how I can easy the pain of configuration as I migrate from dev, to test and to prod.</p>
  
  <p>I've seen JNDI mentioned a lot and at first glance it seems like a good idea. You configure a jndi resource on each tomcat instance and the web context just uses it.</p>
  
  <p>However after examining it further it seems that in order to have a JNDI I've got to have all my database objects + hibernate in the tomcat lib files in order for this to work. This sounds scary to me, what if I want to deploy another context that uses a different version of hibernate?</p>
  
  <p>Also, am I not just swapping the pain of maintaining configuration for the pain of breakages caused by mismatches between the installed jndi resource classes and the ones in my context.</p>
  
  <p>Ideally I think what I'm wanting is to just say in tomcat. There is a database called X, it is at this server and has this user/pass.</p>
  
  <p>I'd appreciate your thoughts on the best way to handle the need for different config in different environments without having an extra step after each deploy to update the config files.</p>
  
  <p>Cheers,
  Peter</p>