java.lang.NoClassDefFoundError: io/cucumber/stepexpression/TypeRegistry

5,196 views
Skip to first unread message

MCD dotCom

unread,
May 20, 2020, 3:42:07 PM5/20/20
to Selenium Users
Hello,

I am learning cucumber. I am trying to create my first project. I am stuck at the below error.

Dependencies:
  <modelVersion>4.0.0</modelVersion>

  <groupId>FreeCRMBDD</groupId>
  <artifactId>FreeCRMBDD</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>FreeCRMBDD</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
  
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.6</version>
    <type>pom</type>
</dependency>
  <dependency>
       <groupId>io.cucumber</groupId>
       <artifactId>cucumber-java</artifactId>
       <version>4.2.6</version>
   </dependency>
   
   
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-jvm</artifactId>
    <version>1.2.6</version>
    <type>pom</type>
</dependency>


<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.6</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-jvm-deps</artifactId>
    <version>1.0.6</version>
</dependency>

<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>5.3.0</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>3.2.0</version>
</dependency>
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-core</artifactId>
    <version>1.2.6</version>
    <type>pom</type>
</dependency>

    
    
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

  </dependencies>
</project>



Step Defintion:

package stepDefinition;

import cucumber.api.java.en.Given;

public class loginStepDef {

@Given("^User is already on login page$")
public void testmethod(){
System.out.println("Test is completed successfully.");

}
}


Runner:
package MyRunner;

import org.junit.runner.RunWith;

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


@RunWith(Cucumber.class)
@CucumberOptions(
features = ("log_In.feature"),
glue="stepDefinition"
        //format= ("pretty","html:test-output")
      )
public class TestRunner {

}


When run the runner as junit, I get an error:


java.lang.NoClassDefFoundError: io/cucumber/stepexpression/TypeRegistry
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at cucumber.runtime.Reflections.hasConstructor(Reflections.java:53)
at cucumber.runtime.Reflections.instantiateSubclasses(Reflections.java:29)
at cucumber.runtime.Runtime.loadBackends(Runtime.java:99)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at cucumber.api.junit.Cucumber.createRuntime(Cucumber.java:78)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:58)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
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:70)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
at org.junit.internal.requests.ClassRequest.createRunner(ClassRequest.java:28)
at org.junit.internal.requests.MemoizingRequest.getRunner(MemoizingRequest.java:19)
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: io.cucumber.stepexpression.TypeRegistry
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 28 more

Please advise!

c2.png
c1.png

Prateek Vaishnav

unread,
May 21, 2020, 2:49:07 AM5/21/20
to seleniu...@googlegroups.com
Where is your feature file? Have you created the feature file? If yes then please provide the folder of feature file in runner class not the feature file name itself.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e735c9f6-7ae2-47b5-adb0-9f146a0a490e%40googlegroups.com.

MCD dotCom

unread,
May 21, 2020, 11:27:06 AM5/21/20
to Selenium Users
Hi,

Please see the attached for feature file. Also please the below runner code. I still have the same issue. 


package MyRunner;


import org.junit.runner.RunWith;


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




@RunWith(Cucumber.class)
@CucumberOptions(

 features
= ("Features")
 
//glue="stepDefinition"
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.
c3.png

Kamal

unread,
May 21, 2020, 11:29:33 AM5/21/20
to Selenium Users
Hi,

Based on the folder structure created by you, following code should work...


@RunWith(Cucumber.class)
@CucumberOptions(
features = "Features",
glue="stepDefinition"
        //format= ("pretty","html:test-output")
      )
public class TestRunner {

}

Prateek Vaishnav

unread,
May 22, 2020, 12:31:36 AM5/22/20
to seleniu...@googlegroups.com
Hi,

We generally provide features folder in src/test/resources folder. Try placing ur features folder there and also try providing absolute path in runner class like 
features="src/test/resources/Features/"



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/dd1ff871-4a25-4632-be8c-d61cfd077c94%40googlegroups.com.

MCD dotCom

unread,
May 22, 2020, 11:26:40 AM5/22/20
to Selenium Users
Problem was with the dependency. I got all io.cucumber dependency and now it worked. 
features="src/test/resources/Features/"



To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages