testng fails from Ant/Ivy with ClassNotFoundException: com.beust.jcommander.ParameterException

4,779 views
Skip to first unread message

Ken Geis

unread,
Dec 6, 2011, 7:28:11 PM12/6/11
to testn...@googlegroups.com
I've attached a simple project that seems like it should work, but I get

   [testng] Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
...
   [testng] Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException

I print the classpath is printed before TestNG is run, and it's clear that JCommander is in the classpath. Now from the size, the testng-6.3.1.jar that's in the Maven repo looks like the distribution jar that has no BSH or Guice. BSH is on the classpath. If you add Guice, it still fails. If you instead use the full testng-6.3.1.jar that's distributed in the TestNG zip, it works fine.

Please look into this.
test.zip

Cédric Beust ♔

unread,
Dec 6, 2011, 7:41:59 PM12/6/11
to testn...@googlegroups.com
Note that this is a NoClassDefFoundException, not ClassNotFoundException...

You're missing something else in your classpath.

-- 
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-dev/-/_n36O816Fc8J.
To post to this group, send email to testn...@googlegroups.com.
To unsubscribe from this group, send email to testng-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-dev?hl=en.

Ken Geis

unread,
Dec 6, 2011, 7:58:01 PM12/6/11
to testn...@googlegroups.com
Caused by: java.lang.ClassNotFoundException

This project is too simple to be missing anything. It only references one class, org.testng.annotations.Test. If there is something missing on the classpath, I'm saying it's not my fault. There seems to be something wrong with the jars or poms that are on the Maven repo.

Ken Geis

unread,
Dec 6, 2011, 8:00:18 PM12/6/11
to testn...@googlegroups.com
Similar thing was posted on StackOverflow. It wasn't fully resolved (the OP used a workaround), so I'm posting a test case that shows the problem.

Cédric Beust ♔

unread,
Dec 6, 2011, 8:12:40 PM12/6/11
to testn...@googlegroups.com
testng.jar in the Maven repository has *no* dependencies, only the TestNG classes. By definition.

If you're using ivy, it should have downloaded all the classes you need, you might want to rm your .ivy directory and try to compile again, just to make sure you don't have a corrupt set of jar files.

-- 
Cédric




On Tue, Dec 6, 2011 at 5:00 PM, Ken Geis <geis...@gmail.com> wrote:
Similar thing was posted on StackOverflow. It wasn't fully resolved (the OP used a workaround), so I'm posting a test case that shows the problem.

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-dev/-/-PuzyduTYBcJ.

Ken Geis

unread,
Dec 6, 2011, 8:40:08 PM12/6/11
to testn...@googlegroups.com
Already tried that.

Cédric Beust ♔

unread,
Dec 6, 2011, 9:15:28 PM12/6/11
to testn...@googlegroups.com
I'm seeing the same problem you are, even with older versions of TestNG. And JCommander is indeed in the classpath that ivy is displaying:

$ javap -classpath /Users/cedric/.ivy2/cache/org.testng/testng/jars/testng-6.3.jar:/Users/cedric/.ivy2/cache/junit/junit/jars/junit-3.8.1.jar:/Users/cedric/.ivy2/cache/org.beanshell/bsh/jars/bsh-2.0b4.jar:/Users/cedric/.ivy2/cache/com.beust/jcommander/jars/jcommander-1.12.jar:/Users/cedric/.ivy2/cache/org.yaml/snakeyaml/jars/snakeyaml-1.6.jar com.beust.jcommander.ParameterException

Compiled from "ParameterException.java"
public class com.beust.jcommander.ParameterException extends java.lang.RuntimeException{
    public com.beust.jcommander.ParameterException(java.lang.Throwable);
    public com.beust.jcommander.ParameterException(java.lang.String);
}

No idea what's going on, I suspect a bug in ivy.

-- 
Cédric




On Tue, Dec 6, 2011 at 5:40 PM, Ken Geis <geis...@gmail.com> wrote:
Already tried that.

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-dev/-/ryTRNDlBMVMJ.

Ken Geis

unread,
Dec 7, 2011, 12:33:52 AM12/7/11
to testn...@googlegroups.com
Thank you very much for looking into it. Sorry for the accusations.

I figured it out. The example I gave was never going to work because it needs to have TestNG on the runtime classpath inside the <testng> task. My project was not working because I was misunderstanding the Ant pathelement path attribute. I was using

       <pathelement path="${testng.classpath}" />                      

when I needed to use

       <pathelement path="${toString:testng.classpath}" />                      
Reply all
Reply to author
Forward
0 new messages