Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IncompatibleClassChangeError when scanning for methods #20

Open
klunk opened this issue Apr 7, 2014 · 4 comments
Open

IncompatibleClassChangeError when scanning for methods #20

klunk opened this issue Apr 7, 2014 · 4 comments

Comments

@klunk
Copy link

klunk commented Apr 7, 2014

Running on a Windows 7 machine with Gradle 1.11, Java 1.7.0_51 and Cucumber JVM 1.1.5 I get the following stacktrace when I try to run the gradlew cucumber command.

org.gradle.api.tasks.TaskExecutionException: Execution failed for task '::cucumber'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpoDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActioExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActioExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:37)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:55)
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:40)
at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:73)
at cucumber.runtime.Runtime.(Runtime.java:89)
at cucumber.runtime.Runtime.(Runtime.java:67)
at cucumber.runtime.Runtime.(Runtime.java:63)
at cucumber.api.cli.Main.run(Main.java:24)
at cucumber.api.cli.Main.main(Main.java:16)
at com.excella.gradle.cucumber.CucumberRunner.runCucumberTests(CucumberRunner.java:74)
at com.excella.gradle.cucumber.CucumberRunner$runCucumberTests.call(Unknown Source)
at com.excella.gradle.cucumber.tasks.CucumberTask.executeCucumberRunner(CucumberTask.groovy:122)
at com.excella.gradle.cucumber.tasks.CucumberTask.cucumber(CucumberTask.groovy:50)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 46 more

I built the plugin from source downloaded via a zip from here as we cannot pull in the distributed jar. I have tried various locations for the feature a steps definitions (steps are defined in Java). The tests run fine within Intellij Idea using both a junit runner and native cucumber support.

@viphe
Copy link
Collaborator

viphe commented Apr 8, 2014

@klunk IncompatibleClassChangeError hints at some library incompatibility or more arcane scenarios. Not sure the stack trace gives us the full info (https://github.com/cucumber/cucumber-jvm/blob/master/java/src/main/java/cucumber/runtime/java/MethodScanner.java#L40).

I just merged a few fix for Windows, but I guess they might not make a difference.

This would require more investigation for sure.

@klunk
Copy link
Author

klunk commented Apr 8, 2014

I seem to have solved the issue, I could see no reason why it would fail as the MethodScanner was calling into the rt.jar of Java and seeing as everything is build with Java 1.7 there should not be an issue and this is the version of the rt.jar that was being picked up at runtime.

Some further investigation with the plugin itself and inserting a few debug statements was showing the test still failing. I then, just by chance, relocated the steps into a new package and it started working.

My project has the cucumber steps in src/cucumber/java with the features in src/cucumber/resources. The steps class was in the com.organisation.project.subproject package, I moved this to a com.organisation.project.subproject.steps package and the tests now run and pass. I dont really understand why this would make a difference, can anyone here think of an explanation?

@viphe
Copy link
Collaborator

viphe commented Apr 10, 2014

Hmm, this could be a bug around the way we collect package names of step implementations: they are specified to Cucumber as classpath glue dirs by scanning the source directories and turning the relative dir path into package names:

src/cucumber/java/my/package/Step.java should be converted to classpath:my.package (if no explicit glue dir has been given in the Gradle build).

It is possible that the implementation is not that good. For instance, generated classes wouldn't make their way to the glue dirs.

See https://github.com/samueltbrown/gradle-cucumber-plugin/blob/master/src/main/groovy/com/excella/gradle/cucumber/tasks/CucumberTask.groovy#L95.

@Star-Wing
Copy link

One way to bypass this error is to use the "glue" option in "CucumberOptions" to specify the path to your step definitions file. If you specify the path for the step-definitions, it helps Cucumber avoid throwing a few errors, like the one given above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants