[cucumber-jvm][junit] java.lang.NoSuchFieldError: BEFORE_CLASS

465 views
Skip to first unread message

DA Bears

unread,
Dec 15, 2017, 5:29:42 PM12/15/17
to Cukes
Hi,
   I am seeing following error when running test. Any clue what might be the issue?

Cucumber version: 1.2.4
Spring version: 4.2.9

java.lang.NoSuchFieldError: BEFORE_CLASS

at org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener.beforeTestClass(DirtiesContextBeforeModesTestExecutionListener.java:77)
at org.springframework.test.context.TestContextManager.beforeTestClass(TestContextManager.java:179)
at cucumber.runtime.java.spring.SpringFactory.notifyContextManagerAboutTestClassStarted(SpringFactory.java:138)
at cucumber.runtime.java.spring.SpringFactory.start(SpringFactory.java:108)
at cucumber.runtime.java.JavaBackend.buildWorld(JavaBackend.java:123)
at cucumber.runtime.Runtime.buildBackendWorlds(Runtime.java:140)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:38)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.api.junit.Cucumber.run(Cucumber.java:98)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


MP Korstanje

unread,
Dec 16, 2017, 11:08:54 AM12/16/17
to Cukes
Bit hard to tell from just the stack trace. I would guess this is caused by using incompatible versions of cucumber-spring and spring.

The project currently only supports a single version of spring. You can fix this by implementing the ObjectFactory for your specific version of spring.

DA Bears

unread,
Dec 18, 2017, 8:55:23 AM12/18/17
to Cukes
Thanks. I will give it a try

DA Bears

unread,
Dec 18, 2017, 8:58:48 AM12/18/17
to Cukes
I just checked the cucumber-spring in depedency:tree of my project. I do not see any spring dependencies being pulled from cucumber-spring.

[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- info.cukes:cucumber-core:jar:1.2.4:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - |  +- info.cukes:cucumber-html:jar:0.2.3:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - |  \- info.cukes:cucumber-jvm-deps:jar:1.0.5:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- info.cukes:cucumber-java:jar:1.2.4:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- info.cukes:cucumber-junit:jar:1.2.4:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - |  \- junit:junit:jar:4.11:test
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- info.cukes:cucumber-spring:jar:1.2.4:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- org.slf4j:slf4j-api:jar:1.6.1:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- ch.qos.logback:com.springsource.ch.qos.logback.core:jar:0.9.28:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - +- ch.qos.logback:com.springsource.ch.qos.logback.classic:jar:0.9.28:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - |  \- org.slf4j:com.springsource.slf4j.api:jar:1.6.1:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo - \- junit:junit:jar:cmeosgi:4.11:compile
[main] INFO org.apache.maven.plugin.dependency.tree.TreeMojo -    \- org.hamcrest:hamcrest-core:jar:1.3:compile
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------

DA Bears

unread,
Dec 18, 2017, 10:45:59 AM12/18/17
to Cukes
Is there any examples of implementing our own ObjectFactory?


On Saturday, December 16, 2017 at 10:08:54 AM UTC-6, MP Korstanje wrote:

Björn Rasmusson

unread,
Dec 18, 2017, 12:21:36 PM12/18/17
to Cukes
DA Bears wrote:
I just checked the cucumber-spring in depedency:tree of my project. I do not see any spring dependencies being pulled from cucumber-spring.

Cucumber-JVM v1.2.4 specifies the spring version as 4.1.6-RELEASE.
Reply all
Reply to author
Forward
0 new messages