Cucumber Exception: java.lang.ClassNotFoundException: cucumber.io.ResourceLoader

4,983 views
Skip to first unread message

Zain Jamshaid

unread,
Aug 13, 2014, 12:40:45 PM8/13/14
to cu...@googlegroups.com

I am facing an error whenever I run the cucumber test by Junit. Here is the following Exception. Any help will be awesome

NOTE:

THERE IS NO ERROR IN THE PROJECT

java.lang.NoClassDefFoundError: cucumber/io/ResourceLoader



 at java
.lang.Class.getDeclaredConstructors0(Native Method)

 at java
.lang.Class.privateGetDeclaredConstructors(Class.java:2398)

 at java
.lang.Class.getConstructor0(Class.java:2708)

 at java
.lang.Class.getConstructor(Class.java:1659)

 at cucumber
.runtime.Reflections.hasConstructor(Reflections.java:53)

 at cucumber
.runtime.Reflections.instantiateSubclasses(Reflections.java:29)

 at cucumber
.runtime.Runtime.loadBackends(Runtime.java:96)

 at cucumber
.runtime.Runtime.<init>(Runtime.java:63)

 at cucumber
.api.junit.Cucumber.createRuntime(Cucumber.java:74)

 at cucumber
.api.junit.Cucumber.<init>(Cucumber.java:61)

 at sun
.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

 at sun
.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

 at sun
.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

 at java
.lang.reflect.Constructor.newInstance(Constructor.java:513)

 at org
.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)

 at org
.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)

 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:26)

 at org
.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)

 at org
.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)

 at org
.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)

 at org
.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)

 at org
.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)

 at org
.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

 at org
.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

 at org
.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.lang.ClassNotFoundException: cucumber.io.ResourceLoader

 at java
.net.URLClassLoader$1.run(URLClassLoader.java:202)

 at java
.security.AccessController.doPrivileged(Native Method)

 at java
.net.URLClassLoader.findClass(URLClassLoader.java:190)

 at java
.lang.ClassLoader.loadClass(ClassLoader.java:306)

 at sun
.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

 at java
.lang.ClassLoader.loadClass(ClassLoader.java:247)

 
... 28 more


Here is how my POM.xml looks like:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">



 
<modelVersion>4.0.0</modelVersion>

 
<groupId>Test</groupId>

 
<artifactId>Cucumber</artifactId>

 
<version>0.0.1-SNAPSHOT</version>

<dependencies>

       
<dependency>

           
<groupId>junit</groupId>

           
<artifactId>junit</artifactId>

           
<version>4.11</version>

       
</dependency>




           
<!-- Cucumber -->  

       
<dependency>

           
<groupId>info.cukes</groupId>

           
<artifactId>cucumber-junit</artifactId>

           
<version>1.1.8</version>

       
</dependency>

       
<dependency>

           
<groupId>org.seleniumhq.selenium</groupId>

           
<artifactId>selenium-chrome-driver</artifactId>

           
<version>2.42.2</version>

       
</dependency>

       
<dependency>

           
<groupId>info.cukes</groupId>

           
<artifactId>cucumber-java</artifactId>

           
<version>1.0.0.RC5</version>

           
<scope>test</scope>

       
</dependency>

</dependencies>

</project>


Here is the image of my project structure:


And here is my RunIT.Java Class

package com.Cucumber;






import org.junit.runner.RunWith;




import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;







@RunWith(Cucumber.class)

@CucumberOptions(

        tags
={"@mysingle"},

        features
= {"."})

public class RunIT {






}



Aslak Hellesøy

unread,
Aug 13, 2014, 12:48:06 PM8/13/14
to cu...@googlegroups.com

On Wednesday, 13 August 2014 at 17:40, Zain Jamshaid wrote:

I am facing an error whenever I run the cucumber test by Junit. Here is the following Exception. Any help will be awesome

Make sure all your cucumber-* jars have the same version. The latest is 1.1.8.

Aslak
 
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zain Jamshaid

unread,
Aug 13, 2014, 1:12:48 PM8/13/14
to cu...@googlegroups.com
Thanks the issue is fixed

Shubham Arya

unread,
Jun 9, 2017, 4:26:31 AM6/9/17
to Cukes
Hi, I am facing the same issue. Can you please help??
Reply all
Reply to author
Forward
0 new messages