Showing posts with label virgo tomcat server. Show all posts
Showing posts with label virgo tomcat server. Show all posts

Wednesday, June 11, 2014

Unable to add any directory into the watched directory chain in virgo tomcat server 3.0.3

Recently I had a requirement where I had to add a directory into the watched directory chain in virgo tomcat server (VTS 3.0.3). Requirement was to check if some jars are present in a particular directory, and if jars are present then add the directory programmatically (using shell script) in the watched directory chain.
So, I created a shell script which looks like below:

if [ -f /usr/local/vts/external_jars/util* ] ; then
echo "Found the util jar under /usr/local/vts/external_jars"
sed -i '
/usr.watchDirectory=repository\/usr/ a\
external_jars.type=watched \
external_jars.watchDirectory=external_jars
' $VTS_HOME/config/org.eclipse.virgo.repository.properties
sed -i "s/usr,/usr,external_jars,/" $VTS_HOME/config/org.eclipse.virgo.repository.properties
fi
When I ran the script it worked all fine, and the configuration file also got updated, but when I restarted my virgo server it did not pick my "external_jars" directory into the chain of watched directory.
I compared the changes with other watched directories but could not find any clue.

Then after struggling a lot I realized that there is a extra space after the value of property "external_jars.type". And as soon as I removed the extra space, it worked.

Corrected script is:

if [ -f /usr/local/vts/external_jars/util* ] ; then
echo "Found the util jar under /usr/local/vts/external_jars"
sed -i '
/usr.watchDirectory=repository\/usr/ a\
external_jars.type=watched\
external_jars.watchDirectory=external_jars
' $VTS_HOME/config/org.eclipse.virgo.repository.properties
sed -i "s/usr,/usr,external_jars,/" $VTS_HOME/config/org.eclipse.virgo.repository.properties
fi

Just thought of sharing this info, so I blogged it.