title: Debugging ant UnsupportedClassVersionError
body: <p>I'm getting the following exception trace as the result of running <code>ant package</code> (this is supposed to create a JBoss <code>.ear</code> package):</p>
  
  <pre><code>$ ant package
  Buildfile: /usr/local/src/appname/build.xml
  
  init:
       [echo] Classpath = ${java.classpath}
  
  build:
  
  package:
  
  BUILD FAILED
  /usr/local/src/appname/build.xml:369: java.lang.UnsupportedClassVersionError: Bad version number in .class file
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
      at org.apache.tools.ant.util.depend.bcel.AncestorAnalyzer.&lt;init&gt;(AncestorAnalyzer.java:45)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
      at java.lang.Class.newInstance0(Class.java:350)
      at java.lang.Class.newInstance(Class.java:303)
      at org.apache.tools.ant.taskdefs.optional.ejb.GenericDeploymentTool.createAnalyzer(GenericDeploymentTool.java:281)
      at org.apache.tools.ant.taskdefs.optional.ejb.GenericDeploymentTool.configure(GenericDeploymentTool.java:308)
      at org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.execute(EjbJar.java:582)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:592)
      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:1360)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
      at org.apache.tools.ant.Main.runBuild(Main.java:801)
      at org.apache.tools.ant.Main.startAnt(Main.java:218)
      at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
      at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
  
  Total time: 0 seconds
  </code></pre>
  
  <p>Is there any way to find out <em>which exactly</em> class file it was trying to load when this exception occurred?</p>
  
  <p>I've tried running with <code>ant -v</code> and <code>ant -debug</code>, but that doesn't add any valuable information about the problem.</p>
  
  <p>As one can see, <code>ant build</code> finishes w/o errors (and also <code>ant clean</code> works.)</p>
  
  <p>I understand something is broken in my setup, but knowing the offending class file name would be of great help to fixing the setup.</p>
  
  <p>Ant and java/javac versions:</p>
  
  <pre><code>$ ant -version
  Apache Ant version 1.8.0 compiled on March 11 2010
  
  $ java -version
  java version "1.5.0_22"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
  Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
  
  $ javac -version
  javac 1.5.0_22
  </code></pre>
  
  <p>OS version:</p>
  
  <pre><code>$ lsb_release -a
  No LSB modules are available.
  Distributor ID: Debian
  Description:    Debian GNU/Linux 6.0.2 (squeeze)
  Release:    6.0.2
  Codename:   squeeze
  </code></pre>
  
  <p>JBoss is installed to <code>/opt/jboss-4.2.3.GA</code>.</p>
  
  <p>Any pointers?</p>