Reputation: 1438
i'm getting really disappointing with an error throw when i try to launch my unit tests with Cucumber.
I get this error :
java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getConstructor(Class.java:1825)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: javax.enterprise.context.spi.Contextual
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 17 more
I already tried to add this lib to my classpath, But this error is still throw with another missing lib, and another etc ...
I've done searches, and nothing of all this libs are required by Cucumber. This is my test class.
@RunWith(Runner.class)
@CucumberOptions(monochrome = true, features = { "src/test-integration/resources/scenarii" }, glue = {
"info.scandi.fusion.cucumber" }, plugin = { "pretty" })
public class AllTests {
}
The paths seems to be correct. And as you can see my steps definition are defined into a jar that i have imported in my project.
My error seems to be related to this stackoverflow question. But i'm not using any root cucumber package.
Any help would be really appreciate.
Upvotes: 0
Views: 433
Reputation: 1438
The problem comes from the slf4j lib. I don't no why. I delete it because it was not use anymore. So now everything works as expected. Thinks.
Upvotes: 0
Reputation: 4343
This is not a Cucumber error. You are missing a dependency that is needed runtime.
My approach for trouble shooting this problem would be to remove as much as possible of the Cucumber configuration until the error disappeared.
I would only keep @RunWith(Cucumber.class)
and then see what happened.
Looking at your JUnit class, I notice that you are using a runner called Runner.class
I don't know what runner this is, but I know that it isn't the JUnit Cucumber runner.
A good starting point for getting started with Cucumber is https://github.com/cucumber/cucumber-java-skeleton
Upvotes: 1