Adrian Stewart Adrian Stewart - 1 year ago 132
Java Question

java.lang.NoClassDefFoundError in Cucumber test package

I am trying to set up a very simple Cucumber test environment using Eclipse. I am following a tutorial and created the project with required reference libraries:

Referenced Libraries

I have created the file with the following content:

package cucumber;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;


plugin = { "pretty", "json:target/cucumber.json" },
features = "src/cucumber"

public class CucumberRunner {


and also create a feature file and step definitions. If I run the from, the feature files, the tests run correctly. But, if I run from the, I get:

java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(
at java.lang.Class.privateGetPublicMethods(
at java.lang.Class.getMethods(
at cucumber.runtime.Runtime.<init>(
at cucumber.runtime.Runtime.<init>(
at cucumber.runtime.Runtime.<init>(
at cucumber.api.junit.Cucumber.createRuntime(
at cucumber.api.junit.Cucumber.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

I have installed the Cucumber Eclipse Plugin as per another answered question so I am at a total loss as to why this is happening. If I try to add JARs to include the missing libraries, I just seem to move the problem to a difference missing library.

I think it must be to do with the versions of libraries I am using but I am a complete novice at this and have no experience of how to problem solve this.

Any help at all would be much appreciated.

Answer Source

As per Sid's comment above, renaming the cucumber class fixed this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download