For the longest time, I was a vi/make or vi/ant guy.  Vi (really VIM) did everything I needed when writing software.  Plus, 25 years of typing in VI really ingrains the finger macros.  About a year ago I made the switch to Netbeans - and I must say that it really is a superior environment to the old standby.  (I'll miss you vi-my old friend, sniff) .

 Netbeans does a great job of supporting the build environment for a web application. It manages all of the complicated deployment descriptors for you and neatly builds a war file that you can deploy to your app server.  It is very easy to build and deploy these web apps.

 Yesterday, I was making a minor change to my web mashup - a change to a constant in the code, and some updates to some HTML.   I built the war file, tested it inside netbeans - everything worked fine - and then deployed it to the external web server - uh oh - no dice - the main page of the web app was only partially loaded, strange javascript errors on the console, nothing is working.  Good thing I had a back up of the previous war file - I uploaded the old version and it worked just fine.

Now to debug this ... since the changes were incredibly minor I couldn't fathom what was causing the problem, add to that the fact that the app ran fine when tested locally.  I suspected a corrupt war file - so I built a new one from scratch and deployed it - same problem.  Argh!  - time to widen the search.   Now one major change was that I did a reinstall of my OS on my laptop (my primary development environment) - so I had a fresh copy of Netbeans and the JDK - perhaps this was the problem - and then there was that magic click that occurs in the programmer brain when everything all falls into place and the solution to the problem becomes clear.  It's the aha! moment that makes programming so much fun.  Of course the problem was that I was building with the latest and greatest JDK 1.6 - while my web server is running a version of Tomcat running under Java 1.5 - way down deep I was receiving class loading errors due to the incompatible classes (you can't run bytecodes compiled with 1.6 under a 1.5 VM).  A quick install of JDK 1.5, a rebuild of the war file - a quick deploy - yep! everything's working now.

This has to be a fairly common error - and it seems that it would be fairly simple for tomcat to detect - it certainly would have saved me time if Tomcat had rejected my war file and given me an error message about the Java version skew during the deploy.


Post a Comment:
Comments are closed for this entry.

This blog copyright 2010 by plamere