title: Deploying a simple web application to Tomcat using Ant
body: <p>I am trying to deploy my simple web application which consists of one web servlet and a JSP. I haven't used any framework such as Spring or anything, just a <em>helloWorld</em> web app.</p>
  
  <p>I am using Ant to for deployment purpose. But when I run my deploy target it gives me:</p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError:
    org/apache/tomcat/util/buf/B2CConverter</p>
  </blockquote>
  
  <p>I am using Tomcat 7 and I have included all libraries under Tomcat lib directory and  <em>tomcat-juli.jar</em> into my <code>webcontent/web-inf/lib</code> as well.</p>
  
  <p>My Ant file targets are as follows:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!-- Configure the directory into which the web application is built --&gt;
      &lt;property name="build" value="${basedir}/build" /&gt;
      &lt;property name="lib.dir" value="${basedir}/WebContent/WEB-INF/lib" /&gt;
      &lt;property name="src.dir" value="${basedir}/src" /&gt;
  
      &lt;!-- Configure the context path for this application --&gt;
      &lt;property name="path" value="/myapp" /&gt;
  
      &lt;!-- Configure properties to access the Manager application --&gt;
      &lt;property name="url" value="http://localhost:8080/manager/text" /&gt;
      &lt;property name="username" value="gbids" /&gt;
      &lt;property name="password" value="tomcat" /&gt;
  
      &lt;!-- Configure the custom Ant tasks for the Manager application --&gt;
      &lt;taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" /&gt;
      &lt;taskdef name="list" classname="org.apache.catalina.ant.ListTask" /&gt;
      &lt;taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" /&gt;
      &lt;taskdef name="findleaks" classname="org.apache.catalina.ant.FindLeaksTask" /&gt;
      &lt;taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask" /&gt;
      &lt;taskdef name="start" classname="org.apache.catalina.ant.StartTask" /&gt;
      &lt;taskdef name="stop" classname="org.apache.catalina.ant.StopTask" /&gt;
      &lt;taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" /&gt;
  
  &lt;!-- Class path --&gt;
      &lt;path id="project.classpath"&gt;
          &lt;fileset dir="${lib.dir}"&gt;
              &lt;include name="**/*.jar" /&gt;
              &lt;include name="**/*.zip" /&gt;
          &lt;/fileset&gt;
      &lt;/path&gt;
  
      &lt;!-- Executable Targets --&gt;
      &lt;target name="compile" description="Compile web application"&gt;
          &lt;javac srcdir="${src.dir}" destdir="${build}/classes" nowarn="on"&gt;
              &lt;classpath refid="project.classpath" /&gt;
          &lt;/javac&gt;
  
      &lt;/target&gt;
  
      &lt;target name="makeWar" depends="compile"&gt;
          &lt;delete file="${build}${path}.war"/&gt;
          &lt;war destfile="${build}${path}.war" webxml="WebContent/WEB-INF/web.xml"&gt;
              &lt;fileset dir="WebContent" /&gt;
              &lt;lib dir="WebContent/WEB-INF/lib" /&gt;
              &lt;classes dir="build/classes" /&gt;
          &lt;/war&gt;
      &lt;/target&gt;
  
      &lt;target name="deploy" description="Install web application" depends="makeWar" &gt;
          &lt;deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${build}${path}.war" /&gt;
      &lt;/target&gt;
  </code></pre>
  
  <p><br>
  And I also have following in my <em>tomcat-users.xml</em> file:</p>
  
  <pre class="lang-xml prettyprint-override"><code>  &lt;role rolename="manager-gui"/&gt;
    &lt;role rolename="admin-gui"/&gt;
    &lt;role rolename="manager-script"/&gt;
  
    &lt;user username="manager" password="tomcat" roles="manager-gui"/&gt;
    &lt;user username="admin" password="tomcat" roles="admin-gui"/&gt;
    &lt;user username="gbids" password="tomcat" roles="manager-script"/&gt;
  </code></pre>
  
  <p>Can anyone please help me to solve this problem.</p>
  
  <p>Thanks</p>