Index: greenstone3/trunk/build.xml
===================================================================
--- greenstone3/trunk/build.xml	(revision 20234)
+++ greenstone3/trunk/build.xml	(revision 20235)
@@ -86,38 +86,4 @@
   </condition>
 
-  <!--
-    the next block checks if tomcat is present in the 'packages' directory, and if so, figures
-    out its major version number (5, 6, etc.)
-    then it checks if your java is new enough to run that tomcat and if not fails with an explanation
-  -->
-  <condition property="packages.tomcat.ispresent" value="true" else="false">
-    <available file="packages/tomcat"/>
-  </condition>
-
-  <if><bool><istrue value="${packages.tomcat.ispresent}"/></bool>
-    <exec os="${os.unix}" outputproperty="packages.tomcat.detected.version" dir="packages/tomcat/bin" executable="sh">
-      <arg value="-c"/>
-      <arg value="./catalina.sh version | grep '^Server version: ' | sed 's@[^0-9]*\([0-9]\).*@\1@g'"/>
-    </exec>
-    <!--
-    totally untested, so commented out for now
-    <exec os="${os.windows}" outputproperty="packages.tomcat.detected.version" dir="packages/tomcat/bin" executable="cmd.exe">
-      <arg value="/c"/>
-      <arg value="catalina.bat version | grep '^Server version: ' | sed 's@[^0-9]*\([0-9]\).*@\1@g'"/>
-    </exec>
-    -->
-    <property name="packages.tomcat.detected.version" value="unknown"/>
-  </if>
-
-  <if>
-    <bool>
-      <and>
-        <istrue value="${packages.tomcat.ispresent}"/>
-        <equals arg1="${packages.tomcat.detected.version}" arg2="6"/>
-        <equals arg1="1.4" arg2="${ant.java.version}"/>
-      </and>
-    </bool>
-    <fail>Your java version (1.4) is too old to work with the bundled version of Apache Tomcat. Please upgrade your java to version 1.5 or greater. Alternatively, you may remove the bundled Apache Tomcat from the 'packages' folder and then run 'ant prepare-tomcat'.</fail>
-  </if>
 
 
@@ -519,4 +485,47 @@
       </and>
     </condition>
+
+    <!--
+      the next block checks if tomcat is present in the 'packages' directory, and if so, figures
+      out its major version number (5, 6, etc.)
+      then it checks if your java is new enough to run that tomcat and if not fails with an explanation
+    -->
+    <condition property="packages.tomcat.ispresent" value="true" else="false">
+      <available file="packages/tomcat"/>
+    </condition>
+
+    <if><bool><istrue value="${packages.tomcat.ispresent}"/></bool>
+      <exec os="${os.unix}" outputproperty="packages.tomcat.detected.version" errorproperty="packages.tomcat.detection.errors" dir="packages/tomcat/bin" executable="sh">
+        <arg value="-c"/>
+        <arg value="./catalina.sh version | grep '^Server version: ' | sed 's@[^0-9]*\([0-9]\).*@\1@g'"/>
+      </exec>
+      <!--
+      totally untested, so commented out for now
+      <exec os="${os.windows}" outputproperty="packages.tomcat.detected.version" dir="packages/tomcat/bin" executable="cmd.exe">
+        <arg value="/c"/>
+        <arg value="catalina.bat version | grep '^Server version: ' | sed 's@[^0-9]*\([0-9]\).*@\1@g'"/>
+      </exec>
+      -->
+      <property name="packages.tomcat.detected.version" value="unknown"/>
+    </if>
+    <!--
+    <echo>packages.tomcat.ispresent: ${packages.tomcat.ispresent}</echo>
+    <echo>packages.tomcat.detected.version: ${packages.tomcat.detected.version}</echo>
+    <echo>packages.tomcat.detection.error: ${packages.tomcat.detection.errors}</echo>
+    -->
+
+    <if>
+      <bool>
+        <or>
+          <and>
+            <istrue value="${packages.tomcat.ispresent}"/>
+            <equals arg1="${packages.tomcat.detected.version}" arg2="6"/>
+            <equals arg1="1.4" arg2="${ant.java.version}"/>
+          </and>
+          <not><equals arg1="${packages.tomcat.detection.errors}" arg2=""/></not>
+        </or>
+      </bool>
+      <fail>Your java version (1.4) is too old to work with the bundled version of Apache Tomcat. Please upgrade your java to version 1.5 or greater. Alternatively, you may remove the bundled Apache Tomcat from the 'packages' folder and then run 'ant prepare-tomcat'.</fail>
+    </if>
 
   </target>
