Fixing $env.TOMCAT_HOME directory creation in eclipse

I ran into this issue when I cloned a Git repository, was running the ant build and was trying to deploy the build to Tomcat.

And every time I did that I got a status of the WAR file being deployed to ${env.TOMCAT_HOME}/webapps.

This created a new directory of the same name in the project....and I could not deploy the project....well because it WAS NOT deployed to Tomcat. ${env.TOMCAT_HOME} was being treated like a 'string' in the ant build...not a variable like it should be.

And I had something looking like this.



I tried looking into setting environment variables on my machine...tried another round hopelessly with root privileges ......to no avail.

To make my temper worse I had done this once before successfully on a friend's computer....had very smartly bookmarked the blogpost that mentioned how to do it and now....that entire blog had been removed.
On a Friday evening after a full day's work...yeah...right.....i know!

Only when I was going to give up I decided to look into the properties of Ant. Not the individual ant builder in my project but Ant properties in Eclipse.

To fix this issue I had to add a property to the Ant runtime for it to recognize the TOMCAT_HOME and therefore deploy it correctly. So do the following.....(seek and thou shall find!!)


  • Eclipse > Preferences > Ant > Runtime. 
  • Click the Properties tab and the 'Add Property...' button. 
  • Then add the TOMCAT_HOME property like this 



  • Click OK > Apply > OK. 
  • Now delete the unwanted ${env.TOMCAT_HOME} folder created, as can be seen in the picture above. 
  • And re run your ant build. This time Ant will treat ${env.TOMCAT_HOME} as a variable, not a string and deploy your build (my WAR) in this case to Tomcat. 
  • Confirm by looking in your Tomcat > webapps folder to find your build. 
TADA!!




Comments

Popular posts from this blog

Accessing Coursera learning material offline

d3 Collapsible tree vertical