title: Ant, Tomcat Build Error: java.lang.NoClassDefFoundError: org/apache/tomcat/util/buf/B2CConverter
body: <p>Tomcat Version: 7.0.20</p>
  
  <p>I am attempting to work my way through the following <em>Spring MVC</em> tutorial:
  <a href="http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html" rel="nofollow">http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html</a></p>
  
  <p>In this tutorial, an <em>ant</em> build script is setup to deploy to tomcat using the manager.  However, I run into some problems when I try to run any of the tomcat tasks.</p>
  
  <p>First off, in the tutorial, they still use <code>org.apache.catalina.ant.InstallTask</code> which is deprecated, so I changed to <code>org.apache.catalina.ant.DeployTask</code>.</p>
  
  <p>Now the problem is that when trying to run the Tomcat tasks I get:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org/apache/tomcat/util/buf/B2CConverter
      at org.apache.catalina.util.Base64.encode(Base64.java:177)
      at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:204)
      at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:150)
      at org.apache.catalina.ant.ReloadTask.execute(ReloadTask.java:45)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      at org.apache.tools.ant.Task.perform(Task.java:348)
      at org.apache.tools.ant.Target.execute(Target.java:390)
      at org.apache.tools.ant.Target.performTasks(Target.java:411)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
      at org.apache.tools.ant.Main.runBuild(Main.java:809)
      at org.apache.tools.ant.Main.startAnt(Main.java:217)
      at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
      at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
   Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.buf.B2CConverter
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      ... 21 more
  </code></pre>
  
  <p>So I Googled around a bit and found some information stating that <code>tomcat-utils.jar</code> should be in the class path so I added that into the fileset with the catalina-ant.jar but apparently the <code>org.apache.tomcat.util.buf.B2CConverter</code> class is not in there.</p>
  
  <p>So next I started probing the jars with <code>jar -tf</code> to find out if any contained the class.  I found out that <code>tomcat-coyote.jar</code> had the class.  Even with including this in the fileset, the problem is not resolved.</p>
  
  <p>Does anyone have any ideas?</p>