JUNIT error: java.lang.NoClassDefFoundError: junit/framework/TestListener

i'm using ant as runner, verytime my junit test finds an error in script i get this errormassage, and my build wont work on...

on class jetbrains.buildServer.agent.ant.AgentJUnitFormatter: java.lang.NoClassDefFoundError: junit/framework/TestListener

i use ant 1.7.1
last week i used ant 1.6.2 and with this it worked great, but i have ot use 1.7.1 becouse of my abbot runner

any idea? or need more information?

Comment actions Permalink

Do you have junit.jar in the classpath? Probably when you used Ant 1.6.2 junit.jar was in the Ant libs.

Pavel Sher

Comment actions Permalink

i got it in classpath, looked now again, and it is. :( but thanks

Comment actions Permalink

I ran into this same error. I verified that the JUnit 4.4 jar was in my classpath and I could run this fine outside of TeamCity. I noticed the ANT_HOME on the build agent was pointing to a specific ANT directory that was not the TeamCity build agent ANT directory (I had another copy of ANT 1.7.0 installed on the server for other purposes). By setting ANT_HOME on the build agent specifically to the TeamCity build agent's ANT directory, this fixed the problem and JUnit is able to execute. You may be able to just remove your ANT_HOME environment variable altogether, but I had issues with that as the build agent was still finding an old ANT_HOME setting somewhere. It may require a server restart that I am not able to do at the moment.

Hope this helps,


Please sign in to leave a comment.