title: servlet action threw exception: java.lang.ClassNotFoundException: org.dom4j.DocumentException when create WEB_INF/lib by ANT build script
body: <p>My project uses ant build script to create WEB_INF/lib folder and copy all jar files into it, and when I run the build.xml , created war file has the WEB_INF/lib folder including all jars, and I have below error in runtime:</p>
  
  <pre><code>servlet action threw exception: java.lang.ClassNotFoundException: org.dom4j.DocumentException
  </code></pre>
  
  <p>but ,If I create WEB_INF/lib folder manually and put dom4j.jar in it, and run the same build.xml, everything works and there is no such errors.</p>
  
  <p>my build.xml file is :</p>
  
  <pre><code>    &lt;project name="hrperf" default="compile"&gt;
  
    &lt;property environment="env"/&gt;
  
    &lt;!-- HUDSON properties --&gt;
    &lt;property name="project.build.no" value="${env.BUILD_NUMBER}"/&gt;
  
    &lt;!-- project properties --&gt;
    &lt;property name="project.name" value="${ant.project.name}"/&gt;
    &lt;property name="project.version" value="6.3.7"/&gt;
  
    &lt;!-- build file debug properties [on|off] --&gt;
    &lt;property name="build.debug" location="on"/&gt;
  
    &lt;!-- path properties --&gt;
    &lt;property name="src.dir" location="src"/&gt;
    &lt;property name="src.resources.dir" location="${src.dir}/com/bchydro/hrperf/resources"/&gt;
    &lt;property name="lib.dir" location="lib"/&gt;
    &lt;property name="build.dir" location="build"/&gt;
    &lt;property name="build.classes.dir" location="${build.dir}/classes"/&gt;
    &lt;property name="dist.dir" location="dist"/&gt;
    &lt;property name="bin.dir" location="bin"/&gt;
    &lt;property name="dist.wartemp.dir" location="${dist.dir}/wartemp"/&gt;
    &lt;property name="dist.wartemp.web-inf.dir" location="${dist.wartemp.dir}/WEB-INF"/&gt;
    &lt;property name="dist.wartemp.web-inf.classes.dir" location="${dist.wartemp.web-inf.dir}/classes"/&gt;
    &lt;property name="dist.wartemp.web-inf.lib.dir" location="${dist.wartemp.web-inf.dir}/lib"/&gt;
    &lt;property name="dist.wartemp.resources.dir" location="${dist.wartemp.web-inf.classes.dir}/com/bchydro/hrperf/resources"/&gt;
    &lt;property name="defaultroot.dir" location="defaultroot"/&gt;
    &lt;property name="db.server.token" value="&amp;lt;set-property property=&amp;quot;url&amp;quot; value=&amp;quot;jdbc:oracle:thin:@EDMEXORCT1:1521:EXWEBTST&amp;quot; /&amp;gt;"/&gt;
    &lt;property name="db.username.token" value="&amp;lt;set-property property=&amp;quot;username&amp;quot; value=&amp;quot;compauth_dev&amp;quot; /&amp;gt;"/&gt;
    &lt;property name="db.password.token" value="&amp;lt;set-property property=&amp;quot;password&amp;quot; value=&amp;quot;compauth_dev1&amp;quot; /&amp;gt;"/&gt;
  
    &lt;!-- Test classpath properties --&gt;
    &lt;property name="test.dir" location="${build.dir}/test"/&gt;
    &lt;property name="test.data.dir" location="${test.dir}/data"/&gt;
    &lt;property name="test.reports.dir" location="${test.dir}/reports"/&gt;
    &lt;property name="javadocs.dir" value="${test.reports.dir}/javadocs"/&gt;
    &lt;property name="lib.junit.dir" location="${lib.dir}/junit-3.8.1"/&gt;
    &lt;property name="junit.jar" value="${lib.junit.dir}/junit.jar"/&gt;
  
    &lt;!-- application properties --&gt;
    &lt;property name="warfile.name" value="${project.name}-${project.version}.${project.build.no}"/&gt;
  &lt;!--  &lt;property name="warfile.region" value="-DEV"/&gt;--&gt;
    &lt;property name="warfile.ext" value=".war"/&gt;
    &lt;property name="hrperf.properties.name" value="hrperf.properties"/&gt;
    &lt;property name="hrperf.messages.name" value="messages.properties"/&gt;
    &lt;property name="log4j.properties.name" value="log4j.properties"/&gt;
    &lt;property name="struts-config.xml.name" value="struts-config.xml"/&gt;
    &lt;property name="struts-db.xml.name" value="struts-db.xml"/&gt;
    &lt;property name="crconfig.xml.name" value="CRConfig.xml"/&gt;
    &lt;property name="package.name" value="hrperf" /&gt;
  
    &lt;!-- lib path properties --&gt;
    &lt;property name="servlet.jar" value="${lib.servlet.dir}/servlet.jar"/&gt;
    &lt;property name="lib.dbcp.dir" location="${lib.dir}/commons-dbcp-1.4"/&gt;
    &lt;property name="lib.pool.dir" location="${lib.dir}/commons-pool-1.6"/&gt;
    &lt;property name="lib.log4j.dir" location="${lib.dir}/jakarta-log4j-1.2.8"/&gt;
    &lt;property name="lib.struts.dir" location="${lib.dir}/jakarta-struts-1.2.6"/&gt;
    &lt;property name="lib.jdbc.dir" location="${lib.dir}/jdbc"/&gt;
    &lt;property name="lib.jstl.dir" location="${lib.dir}/jstl"/&gt;
    &lt;property name="lib.mail.dir" location="${lib.dir}/mail"/&gt;
    &lt;property name="lib.servlet.dir" location="${lib.dir}/servlet"/&gt;
    &lt;property name="lib.displaytag.dir" location="${lib.dir}/displaytag-1.0"/&gt;
    &lt;property name="lib.jfreecharttag.dir" location="${lib.dir}/jfreechart"/&gt;
    &lt;property name="lib.cewolf.dir" location="${lib.dir}/cewolf"/&gt;
    &lt;property name="lib.crystal.dir" location="${lib.dir}/crystal"/&gt;
    &lt;property name="lib.cloning.dir" location="${lib.dir}/cloning-1.9.0"/&gt;
    &lt;property name="lib.cobertura.dir" location="${lib.dir}/cobertura-1.8"/&gt;
    &lt;property name="lib.poi.dir" location="${lib.dir}/poi-3.9"/&gt;  
    &lt;property name="lib.commons-fileupload.dir" location="${lib.dir}/commons-fileupload"/&gt;
    &lt;property name="lib.commons-io.dir" location="${lib.dir}/commons-io"/&gt;
    &lt;property name="lib.commons-collections.dir" location="${lib.dir}/commons-collections"/&gt;
    &lt;property name="lib.dom4j.dir" location="${lib.dir}/dom4j-1.6.1"/&gt;
    &lt;property name="lib.gson.dir" location="${lib.dir}/gson"/&gt;
  
    &lt;!-- classpath properties --&gt;
    &lt;property name="log4j.jar" value="${lib.log4j.dir}/log4j-1.2.8.jar"/&gt;
    &lt;property name="struts.jar" value="${lib.struts.dir}/struts.jar"/&gt;
    &lt;property name="jstl.jar" value="${lib.jstl.dir}/jstl.jar"/&gt;
    &lt;property name="standard.jar" value="${lib.jstl.dir}/standard.jar"/&gt;
    &lt;property name="mail.jar" value="${lib.mail.dir}/mail.jar"/&gt;
    &lt;property name="displaytag.jar" value="${lib.displaytag.dir}/displaytag-1.0.jar"/&gt;
    &lt;property name="jfreecharttag.jar" value="${lib.jfreecharttag.dir}/jfreechart-1.0.0-rc1.jar"/&gt;
    &lt;property name="jcommon.jar" value="${lib.jfreecharttag.dir}/jcommon-1.0.0-rc1.jar"/&gt;
    &lt;property name="cewolf.jar" value="${lib.cewolf.dir}/cewolf.jar"/&gt;
    &lt;property name="dom4j.jar" value="${lib.dom4j.dir}/dom4j-1.6.1.jar"/&gt;
    &lt;property name="gson-2.2.4-sources.jar" value="${lib.gson.dir}/gson-2.2.4-sources.jar"/&gt;
    &lt;property name="gson-2.2.4.jar" value="${lib.gson.dir}/gson-2.2.4.jar"/&gt;
  
    &lt;!-- Classpath properties --&gt;
    &lt;property name="cobertura.jar" value="${lib.cobertura.dir}/cobertura-1.8.jar"/&gt;
  
    &lt;!-- cobertura serialized filename --&gt;
    &lt;property name="cobertura.ser.name" value="${test.data.dir}/cobertura.ser"/&gt;
  
    &lt;!-- Crystal Reports Libraries --&gt;
    &lt;property name="cloning.jar" value="${lib.cloning.dir}/*.jar"/&gt;
    &lt;property name="crystal.jar" value="${lib.crystal.dir}/*.jar"/&gt;
  
    &lt;!--
      =======================================================================
      Classpaths
      =======================================================================
    --&gt;
    &lt;!-- compile classpath --&gt;
    &lt;path id="compile.classpath"&gt;
      &lt;pathelement location="${log4j.jar}"/&gt;
      &lt;pathelement location="${struts.jar}"/&gt;
      &lt;pathelement location="${jstl.jar}"/&gt;
      &lt;pathelement location="${standard.jar}"/&gt;
      &lt;pathelement location="${servlet.jar}"/&gt;
      &lt;pathelement location="${mail.jar}"/&gt;
      &lt;pathelement location="${displaytag.jar}"/&gt;
      &lt;pathelement location="${jfreecharttag.jar}"/&gt;
      &lt;pathelement location="${jcommon.jar}"/&gt;
      &lt;pathelement location="${cewolf.jar}"/&gt;
      &lt;pathelement location="${dom4j.jar}"/&gt;
      &lt;pathelement location="${gson-2.2.4-sources.jar}"/&gt;
      &lt;pathelement location="${gson-2.2.4.jar}"/&gt;
      &lt;!-- Crystal Reports jar files --&gt;
      &lt;pathelement location="${crystal.jar}"/&gt;
      &lt;fileset dir="lib"&gt;
        &lt;include name="**/*.jar"/&gt;
      &lt;/fileset&gt;
    &lt;/path&gt;
  
    &lt;!-- Test classpath --&gt;
    &lt;path id="test.classpath"&gt;
      &lt;path refid="compile.classpath" /&gt;
      &lt;pathelement location="${junit.jar}"/&gt;
      &lt;pathelement location="${build.dir}/classes"/&gt;
      &lt;pathelement location="${build.dir}/test"/&gt;
    &lt;/path&gt;
  
    &lt;!-- Cobertura classpath --&gt;
    &lt;path id="cobertura.classpath"&gt;
      &lt;path refid="test.classpath"/&gt;
      &lt;fileset dir="${lib.log4j.dir}" includes="**/*.jar"/&gt;
      &lt;fileset dir="${lib.cobertura.dir}" includes="**/*.jar"/&gt;
    &lt;/path&gt;
  </code></pre>
  
  <p>And the task to create the war file is as bellow:</p>
  
  <pre><code> &lt;!-- STAGING --&gt;
    &lt;target name="staging" depends="packageinit"&gt;
      &lt;!-- Load Application Properties File --&gt;
      &lt;property file="${src.resources.dir}/hrperf.staging.properties" /&gt;
  
      &lt;!-- copy struts DB file --&gt;
      &lt;copy file="${dist.wartemp.web-inf.dir}/struts-db-staging.xml" tofile="${dist.wartemp.web-inf.dir}/${struts-db.xml.name}" overwrite="true"/&gt;
      &lt;!-- remove development, staging, esc and production struts-db files --&gt;
      &lt;delete&gt;
          &lt;fileset dir="${dist.wartemp.web-inf.dir}" includes="*-development.xml, *-staging.xml, *-esc.xml, *-production.xml"/&gt;
      &lt;/delete&gt;
  
      &lt;!-- copy resource files --&gt;
      &lt;copy file="${src.resources.dir}/hrperf.staging.properties"     tofile="${dist.wartemp.resources.dir}/${hrperf.properties.name}"/&gt;
      &lt;copy file="${lib.log4j.dir}/log4j.staging.properties" tofile="${dist.wartemp.web-inf.classes.dir}/${log4j.properties.name}" overwrite="true"/&gt;
  
      &lt;property name="warfile.region" value="-test"/&gt;
      &lt;antcall target="warfinal"/&gt;
    &lt;/target&gt;
  </code></pre>
  
  <p>could you please give me advice to solve the problem?
  Thanks,</p>