title: java.uti.zip.ZipException error while calling a ant target
body: <p>While calling a ANT target, I am getting the below error. I tried my level best solve the issue but not.</p>
  
  <pre><code>Unable to obtain resource from C:\uiunit\log4j.properties: java.util.zip.ZipException: error in opening zip file
  [junit] Unable to obtain resource from C:\uiunit\log4j.properties:
  [junit] java.util.zip.ZipException: error in opening zip file
  [junit]     at java.util.zip.ZipFile.open(Native Method)
  [junit]     at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:214)
  [junit]     at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:144)
  [junit]     at java.util.jar.JarFile.&lt;init&gt;(JarFile.java:152)
  [junit]     at java.util.jar.JarFile.&lt;init&gt;(JarFile.java:116)
  [junit]     at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1006)
  [junit]     at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:149)
  [junit]     at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.&lt;init&gt;(AntClassLoader.java:110)
  [junit]     at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:953)
  [junit]     at org.apache.tools.ant.AntClassLoader.getNamedResources(AntClassLoader.java:922)
  [junit]     at org.apache.tools.ant.loader.AntClassLoader5.getResources(AntClassLoader5.java:58)
  [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.checkForkedPath(JUnitTask.java:1181)
  [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked(JUnitTask.java:1061)
  [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:855)
  [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1903)
  [junit]     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:804)
  [junit]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
  [junit]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
  [junit]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  [junit]     at java.lang.reflect.Method.invoke(Method.java:601)
  [junit]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
  [junit]     at org.apache.tools.ant.Task.perform(Task.java:348)
  [junit]     at org.apache.tools.ant.Target.execute(Target.java:435)
  [junit]     at org.apache.tools.ant.Target.performTasks(Target.java:456)
  [junit]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
  [junit]     at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
  [junit]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
  [junit]     at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
  [junit]     at org.apache.tools.ant.Main.runBuild(Main.java:851)
  [junit]     at org.apache.tools.ant.Main.startAnt(Main.java:235)
  [junit]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
  [junit]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
  [junit] DEBUG com.cordys.cm.uiunit.config.IConfiguration - Using config file: "/C:/uiunit/UIUnit.properties" (-2009166949)
  [junit] null
  [junit] Running test.CapsInstallerTest
  [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.184 sec
  [junit] Test test.CordysCapsInstallerTest FAILED
  </code></pre>
  
  <p>[junitreport] Processing D:\checkouts\GUIInstaller\TESTS-CapsInstallerTest-Suites.xml to D:\checkouts\GUIInstaller\guiunit.build.junit.report\junit-nof
  [junitreport] Loading stylesheet jar:file:/D:/checkouts/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-noframes.xsl
  [junitreport] Transform time: 499ms</p>
  
  <p>Observation:- If I perform compile operation through eclipse then ANT target call is working wise. Bu If I perform compile operation through ANT then ANT target call is failing with the above error.</p>
  
  <h1>Buil.xml File content</h1>
  
  <pre><code>&lt;project name="GUITest" basedir="." default="installBOP"&gt;
  &lt;property environment="env" /&gt;
  &lt;property file="installer.properties"/&gt;
  &lt;property file="uninstaller.properties"/&gt;
  &lt;property file="c:/uiunit/uiunit.properties" /&gt;
  &lt;property name="src" location="src" /&gt;
  &lt;property name="src.test" location="src/test" /&gt;
  &lt;property name="fit" location="fit" /&gt;
  &lt;property name="bin" location="bin" /&gt;
  &lt;property name="lib" location="lib" /&gt;
  &lt;property name="guiunit.build.junit.report" location="guiunit.build.junit.report" /&gt;
  &lt;property name="report" location="report" /&gt;
  &lt;property name="report.run" location="report/run" /&gt;
  &lt;property name="REPORTNAME" location="CordysCapsInstallerTest" /&gt;
  
  &lt;path id="lib.classpath"&gt;
  &lt;fileset dir="${lib}"&gt;
      &lt;include name="**/*.jar" /&gt;
  &lt;/fileset&gt;
  &lt;/path&gt;
  
      &lt;path id="test.classpath"&gt;
      &lt;path refid="lib.classpath" /&gt;
      &lt;pathelement location="${bin}" /&gt;
      &lt;pathelement location="C:/uiunit" /&gt;
      &lt;/path&gt;
  
  &lt;condition property="OsName" value="Windows"&gt;
      &lt;os family="windows"/&gt;
  &lt;/condition&gt;
  &lt;condition property="OsName" value="Linux"&gt;
      &lt;os name="Linux"/&gt;
  &lt;/condition&gt;
  &lt;condition property="OsName" value="aix"&gt;
      &lt;os name="AIX"/&gt;
  &lt;/condition&gt;
  &lt;condition property="OsName" value="SunOS"&gt;
      &lt;os name="SunOS"/&gt;
  &lt;/condition&gt;
  &lt;condition property="isUnix"&gt;
      &lt;os family="unix"/&gt;
  &lt;/condition&gt;
  &lt;condition property="onOracle"&gt;
      &lt;equals arg1="${env.DB_VENDOR_NAME}" arg2="Oracle 9i / 10g / 11g"/&gt;
  &lt;/condition&gt;
  &lt;condition property="onWindows"&gt;
      &lt;os family="Windows"/&gt;
  &lt;/condition&gt;
  &lt;condition property="onLinux"&gt;
      &lt;os name="Linux"/&gt;
  &lt;/condition&gt;
  &lt;condition property="onAix"&gt;
      &lt;os name="AIX"/&gt;
  &lt;/condition&gt;
  
  &lt;condition property="is64bit" value="-64bit" else=""&gt;
      &lt;and&gt;
          &lt;os arch="amd64"/&gt;
          &lt;not&gt;
              &lt;equals arg1="${branch.name}" arg2="BOP4-CU"/&gt;
          &lt;/not&gt;
          &lt;not&gt;
              &lt;equals arg1="${branch.name}" arg2="BOP4-CU-Release"/&gt;
          &lt;/not&gt;
      &lt;/and&gt;
  &lt;/condition&gt;
  
  &lt;target name="help"&gt;
      &lt;echo&gt;ant upgrade: Upgrade the cordys&lt;/echo&gt;
      &lt;echo&gt;ant install: Install the cordys&lt;/echo&gt;
      &lt;echo&gt;ant uninstall: Uninstall the cordys&lt;/echo&gt;
  &lt;/target&gt;
  
  &lt;target name="clean"&gt;
      &lt;delete dir="${bin}" /&gt;
      &lt;delete dir="${report}" /&gt;
  &lt;/target&gt;
  
  &lt;target name="compile" depends="clean"&gt;
      &lt;mkdir dir="${bin}" /&gt;
      &lt;!--&lt;javac includeantruntime="false" srcdir="${src}" destdir="${bin}"&gt;
          &lt;classpath refid="test.classpath" /&gt;            
      &lt;/javac&gt;--&gt;
      &lt;javac destdir="${bin}" debug="${debug}" nowarn="${debug}" deprecation="${deprecation}" optimize="${optimize}"&gt;
          &lt;classpath refid="test.classpath" /&gt;
          &lt;src path="${src}" /&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  
  &lt;target name="copy-installer" unless="dont.download"&gt;
      &lt;echo message="Fetching build number...." /&gt;
      &lt;taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${lib}/commons-net-2.2.jar" /&gt;
      &lt;ftp
          action="get"
          server="${ftp.server.name}"
          userid="${ftp.user.name}"
          remotedir="${ftp.remote.dir}/${branch.name}"
          password="${ftp.user.password}"
          passive="true"&gt;
          &lt;fileset  dir="${basedir}"&gt;
              &lt;include name="build.number" /&gt;
              &lt;include name="build.properties"/&gt;
          &lt;/fileset&gt;
      &lt;/ftp&gt;
      &lt;move file="build.number" tofile="buildnumber.properties"/&gt;
      &lt;property file="${basedir}/build.properties"/&gt;
      &lt;property file="${basedir}/buildnumber.properties"/&gt;
      &lt;delete dir="${basedir}/installers" failonerror="false"/&gt;
      &lt;condition property="buildfolder" value="" else="/build.${build.number}"&gt;
          &lt;or&gt;
              &lt;equals arg1="${branch.name}" arg2="BOP4-CU"/&gt;
              &lt;equals arg1="${branch.name}" arg2="BOP4-CU-Release"/&gt;
          &lt;/or&gt;
      &lt;/condition&gt;
      &lt;echo message="Fetching installer.... from ${ftp.remote.dir}/${branch.name}${buildfolder}/external/${OsName}${is64bit}" /&gt;
      &lt;ftp
          action="get"
          server="${ftp.server.name}"
          userid="${ftp.user.name}"
          remotedir="${ftp.remote.dir}/${branch.name}${buildfolder}/external/${OsName}${is64bit}"
          password="${ftp.user.password}" 
          passive="true"&gt;
          &lt;fileset  dir="${basedir}/installers"&gt;
              &lt;include name="${name.dist.zip.file}"/&gt;
          &lt;/fileset&gt;
       &lt;/ftp&gt;
      &lt;unzip src="${basedir}/installers/${name.dist.zip.file}" dest="${basedir}/installers"/&gt;
      &lt;chmod dir="${basedir}/installers" perm="ugo+rx" includes="*.bin" osfamily="unix"/&gt;
      &lt;delete file="${basedir}/installers/${name.dist.zip.file}"/&gt;
  &lt;/target&gt;
  
   &lt;target name="installTilBaseline" depends="compile,copy-installer"&gt;
      &lt;echo message="${log4j.rootCategory}"/&gt;
      &lt;mkdir dir="${report.run}" /&gt;        
      &lt;java fork="true" classname="test.GUITest" failonerror="true"&gt;
          &lt;arg line="install"/&gt;
          &lt;!--jvmarg line="-Dlog4j.configuration=${basedir}/lib/log4j.properties"/--&gt;
          &lt;classpath&gt;
              &lt;path refid="test.classpath"/&gt;
              &lt;path location = "$(bin)" /&gt;
              &lt;pathelement location="${env.JAVA_HOME}/lib/tools.jar"/&gt;
              &lt;pathelement location="${env.Path}"/&gt;
          &lt;/classpath&gt;            
      &lt;/java&gt;
      &lt;echo message="${env.classpath}"/&gt;      
  &lt;/target&gt;
  
  &lt;target name="uninstallBOP" depends="compile"&gt;
      &lt;mkdir dir="${report.run}" /&gt;        
          &lt;java fork="true" classname="test.GUITest" failonerror="true"&gt;
              &lt;arg line="uninstall"/&gt;
              &lt;classpath&gt;
                  &lt;path refid="test.classpath"/&gt;
                  &lt;path location = "$(bin)" /&gt;
                  &lt;pathelement location="${env.JAVA_HOME}/lib/tools.jar"/&gt;
                  &lt;pathelement location="${env.Path}"/&gt;
              &lt;/classpath&gt;
          &lt;/java&gt;
      &lt;echo&gt;Please see the run report page for more details&lt;/echo&gt;        
  &lt;/target&gt;
  
  &lt;target name="upgradeTilBaseline" depends="compile,copy-installer"&gt;
      &lt;mkdir dir="${report.run}" /&gt;        
          &lt;java fork="true" classname="test.GUITest" failonerror="true"&gt;
              &lt;arg line="upgrade"/&gt;
              &lt;classpath&gt;
                  &lt;path refid="test.classpath"/&gt;
                  &lt;path location = "$(bin)" /&gt;
                  &lt;pathelement location="${env.JAVA_HOME}/lib/tools.jar"/&gt;
                  &lt;pathelement location="${env.Path}"/&gt;
              &lt;/classpath&gt;
          &lt;/java&gt;
      &lt;echo&gt;Please see the run report page for more details&lt;/echo&gt;
  &lt;/target&gt;
  
  &lt;target name="launch-rc-server" if="${selenium.server.ant}" &gt;
      &lt;mkdir dir="${report.run}"/&gt;
      &lt;taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${lib}/ant-contrib-1.0b1.jar" /&gt;
      &lt;taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpath="${lib}/antelopetasks-3.2.10.jar" /&gt;
      &lt;stringutil string="${seleniumserver}" property="indexofcom"&gt;
          &lt;indexof string=":" /&gt;
      &lt;/stringutil&gt;
      &lt;stringutil string="${seleniumserver}" property="temp"&gt;
          &lt;substring beginindex="${indexofcom}" /&gt;
      &lt;/stringutil&gt;
      &lt;stringutil string="${temp}" property="hub.port"&gt;
          &lt;replace regex=":" replacement="" /&gt;
      &lt;/stringutil&gt;
      &lt;if&gt;
      &lt;equals arg1="${browsertype}" arg2="safariproxy" /&gt;
      &lt;then&gt;
          &lt;property name="selenium.server" value="selenium-server-standalone-2.0b3.jar"/&gt;
      &lt;/then&gt;
      &lt;else&gt;
          &lt;property name="selenium.server" value="selenium-server-standalone-2.32.0.jar"/&gt;
      &lt;/else&gt;
      &lt;/if&gt;
      &lt;if&gt;
          &lt;istrue value="${browser.session.reuse}"/&gt;
          &lt;then&gt;
              &lt;property name="temp.selenium.args" value="-port ${hub.port} -browserSessionReuse" /&gt;
          &lt;/then&gt;
          &lt;else&gt;
              &lt;property name="temp.selenium.args" value="-port ${hub.port}" /&gt;
          &lt;/else&gt;
      &lt;/if&gt;
      &lt;if&gt;
          &lt;isset  property="selenium.args.custom"/&gt;
          &lt;then&gt;
              &lt;property name="selenium.args" value="${temp.selenium.args} ${selenium.args.custom}" /&gt;
          &lt;/then&gt;
          &lt;else&gt;
              &lt;property name="selenium.args" value="${temp.selenium.args}" /&gt;
          &lt;/else&gt;
      &lt;/if&gt;
      &lt;echo&gt;/K start java -jar lib/${selenium.server} ${selenium.args}&lt;/echo&gt;
      &lt;exec dir="." executable="cmd" spawn="false" output="${report.run}/startsel-output.txt" logerror="true"&gt;
          &lt;arg line="/K start java -jar lib/${selenium.server} ${selenium.args}"/&gt;
      &lt;/exec&gt;
      &lt;sleep seconds="10"/&gt;
      &lt;antcall target="waitForSeleniumServer" /&gt;
  &lt;/target&gt;
  
  &lt;target name="waitForSeleniumServer" description="wait till selenium server starts"  if="${selenium.server.ant}"&gt;
      &lt;echo taskname="waitfor" message="Wait for proxy server launch" /&gt;
      &lt;waitfor maxwait="2" maxwaitunit="minute" checkevery="100"&gt;
          &lt;http url="http://${seleniumserver}/selenium-server/driver/?cmd=testComplete"/&gt;
      &lt;/waitfor&gt;
  &lt;/target&gt;
  
  &lt;target name="shutdown-rc-server" description="this will shutdown RC" if="${selenium.server.ant}"&gt;
      &lt;echo&gt;seleniumserver is ${seleniumserver}&lt;/echo&gt;
      &lt;java classname="com.selenium.remotecontrol.ShutDownRC" fork="true" failonerror="true"&gt;
          &lt;jvmarg value="-Durl=http://${seleniumserver}" /&gt;
          &lt;classpath&gt;
              &lt;fileset dir="${basedir}/lib"&gt;
                  &lt;include name="commons-httpclient-3.0.1.jar" /&gt;
                  &lt;include name="commons-logging-*.jar" /&gt;
                  &lt;include name="commons-codec-1.5.jar" /&gt;
                  &lt;include name="shutdownrc.jar" /&gt;
              &lt;/fileset&gt;
          &lt;/classpath&gt;
      &lt;/java&gt;
      &lt;sleep seconds="3"/&gt;
  &lt;/target&gt;
  
  &lt;target name="installcaps" depends="launch-rc-server"&gt;
  &lt;echo&gt;${test.classpath}&lt;/echo&gt;
  &lt;mkdir dir="${guiunit.build.junit.report}" /&gt;
  &lt;!-- do necessary setup--&gt;
  &lt;junit fork="yes" failureproperty="junit.failed" dir="${basedir}"
      filtertrace="on" 
      haltonfailure="no" printsummary="on"
      showoutput="yes"&gt;
      &lt;classpath&gt;
          &lt;path refid="test.classpath"/&gt;
          &lt;pathelement location="${env.JAVA_HOME}/lib/tools.jar"/&gt;
          &lt;pathelement location="${env.Path}"/&gt;
          &lt;pathelement location="${bin}"/&gt;
      &lt;/classpath&gt;        
      &lt;formatter type="xml"/&gt;
      &lt;test name="test.CordysCapsInstallerTest" todir="${guiunit.build.junit.report}"/&gt;
  &lt;/junit&gt;
  &lt;junitreport tofile="TESTS-CordysCapsInstallerTest-Suites.xml"&gt;
      &lt;fileset dir="${guiunit.build.junit.report}"&gt;
          &lt;include name="**/TEST-*.xml"/&gt;
      &lt;/fileset&gt;
      &lt;report format="noframes" todir="${guiunit.build.junit.report}"/&gt;
  &lt;/junitreport&gt;
  &lt;antcall target="shutdown-rc-server" /&gt;
  &lt;/target&gt;
  
  &lt;target name="installBOP" depends="installTilBaseline,installcaps"&gt;
      &lt;echo&gt;Installation of BOP is completed&lt;/echo&gt;
  &lt;/target&gt;
  
  &lt;target name="upgradeBOP" depends="upgradeTilBaseline,installcaps"&gt;
      &lt;echo&gt;Upgrade of BOP is completed&lt;/echo&gt;
  &lt;/target&gt;
  
  &lt;target name="buildjar"&gt;
  
  &lt;/target&gt;
  </code></pre>
  
  <p></p>
  
  <p>when I am calling $> <strong>ant installcaps</strong> target previously I used to get the above error, after that by following <strong>Guillaume Darmont</strong> comment I removed the <strong>C:\uiunit\log4j.properties</strong> value from class path, then I landed in to the below error</p>
  
  <pre><code>D:\checkouts\GUIInstaller&gt;ant installcaps
  </code></pre>
  
  <p>Buildfile: D:\checkouts\GUIInstaller\build.xml</p>
  
  <p>launch-rc-server:
      [mkdir] Created dir: D:\checkouts\GUIInstaller\report\run
       [echo] /K start java -jar lib/selenium-server-standalone-2.32.0.jar -port 4444</p>
  
  <p>waitForSeleniumServer:
    [waitfor] Wait for proxy server launch</p>
  
  <p>installcaps:
       [echo] ${test.classpath}
      [junit] DEBUG com.cordys.cm.uiunit.config.IConfiguration - Using config file: "/C:/uiunit/UIUnit.properties" (-2009166949)
      [junit] Running test.CordysCapsInstallerTest
      [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.191 sec
      [junit] Test test.CordysCapsInstallerTest FAILED
  [junitreport] Processing D:\checkouts\GUIInstaller\TESTS-CordysCapsInstallerTest-Suites.xml to D:\checkouts\GUIInstaller\guiunit.build.junit.report\junit-noframes.html
  [junitreport] Loading stylesheet jar:file:/D:/checkouts/ant/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-noframes.xsl
  [junitreport] Transform time: 524ms</p>
  
  <p>shutdown-rc-server:
       [echo] seleniumserver is cin400695:4444
       [java] RC running in .........:4444 is shutdown</p>
  
  <p>BUILD SUCCESSFUL
  Total time: 17 seconds</p>
  
  <p>And in the log files I seen the below error.</p>
  
  <pre><code>testcase classname="test.CordysCapsInstallerTest" name="initializationError0" time="0.007"&gt;
        &lt;error type="java.lang.NullPointerException"&gt;java.lang.NullPointerException
  at java.util.TreeMap.compare(TreeMap.java:1188)
  at java.util.TreeMap.put(TreeMap.java:531)
  at com.cordys.cm.uiunit.junit4.internal.runners.UIUnitClassMethodsRunner.getTestMethods(UIUnitClassMethodsRunner.java:168)
  at com.cordys.cm.uiunit.junit4.internal.runners.UIUnitClassMethodsRunner.&amp;lt;init&amp;gt;(UIUnitClassMethodsRunner.java:45)
  at com.cordys.cm.uiunit.junit4.runners.UIUnitRunner.&amp;lt;init&amp;gt;(UIUnitRunner.java:15)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
  </code></pre>
  
  <p></p>
  
  <pre><code>  &lt;/testcase&gt;
  </code></pre>