Exception in thread "main" cucumber.runtime.CucumberException: No backends were found - java

I am developing my Selenium-JVM framework with Cucumber and while running my first feature got below error.
Please help.
How did I launch the feature -
Right click on feature file
Select Run As -> Cucumber Feature
Immediate Exception -
Exception in thread "main" cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
at cucumber.runtime.Runtime.<init>(Runtime.java:78)
at cucumber.runtime.Runtime.<init>(Runtime.java:67)
at cucumber.runtime.Runtime.<init>(Runtime.java:63)
at cucumber.api.cli.Main.run(Main.java:24)
at cucumber.api.cli.Main.main(Main.java:16)
What I have in code -
Launcher.java -
package cucumber;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(format={"pretty","json:target/"} , features="/src/test/java/cucumber/features")
public class Launcher {
}
Feature file -
Feature: it works demo
Scenario: First test
Given this is my step
When this is my second step
Then this is my final step
List of Dependencies added to list -
cucumber-core-1.1.8
cucumber-html-0.2.3
cucumber-java-1.1.8
cucumber-junit-1.1.8
cucumber-jvm-deps-1.0.3
gherkin-2.12.2
hamcrest-all-1.3
junit-4.11
selenium-api-2.42.2
selenium-firefox-driver-2.42.2
selenium-java-2.42.2
selenium-remote-driver-2.42.2
selenium-support-2.42.2
My JVM - 1.7
Only this much is available in project.
Please help.

Make sure you're adding below dependencies for Maven project:
You can replace version to the latest or the required version:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.0</version>
</dependency>

This error is thrown when no 'backends' are found on the classpath. There is a 'backend' for each supported language (e.g. cucumber-java, cucumber-groovy etc.)
It's probably a classpath error, although if cucumber-core and cucumber-java are in the same location that does seem strange.

Used the latest and same version for all dependencies and it works fine.
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>6.11.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.11.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.11.0</version>
</dependency>
</dependencies>

You can try the cucumber-java-1.2.4 at https://mvnrepository.com/artifact/info.cukes/cucumber-java/1.2.4.
I found that trying a previous version of the same JAR file worked for me.
I guess this may solve for other people as well. In case it does not, please add another answer.
Let me know if it worked for you and saved some valuable time :-)

Writing in 2020, though enough discussion has already gone on this topic. Still if it helps someone. For me the issue got resolved with same version of
cucumber-java
cucumber-junit
cucumber-core
dependencies
snippet of my POM
io.cucumber
cucumber-java
6.4.0
io.cucumber
cucumber-core
6.4.0
io.cucumber
cucumber-junit
6.4.0
compile

You are not providing the path of the step definition class
Add glue in the cucumber options may be it will help.
#RunWith(Cucumber.class) #CucumberOptions(
features ="Path of the feature file",
glue = {"path of step definition class or package "},
format={"pretty","json:target/"},
dryRun = true,
strict = true,
monochrome = true )

I got this same error message when trying to run a Cucumber feature file in Eclipse.
These steps worked for me:
Updated my pom.xml file with the latest and same version of the following libraries.
cucumber-junit - 1.2.6
cucumber-java - 1.2.6
Also I updated 'junit' to the latest version

Here is the fix:
in eclipse projects add the following in the .project file
<buildSpec>
...
<buildCommand>
<name>cucumber.eclipse.steps.jdt.stepsBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
...
<nature>cucumber.eclipse.steps.jdt.stepsNature</nature>
</natures>
If this did not fix the issue,
add the dependency
cucumber-java
in the project classpath or change the version of the jar to latest or n-1

i had pom in my dependency for cucumber-java. Once i removed that worked fine

I have updated my pom.xml file with the latest version of following libraries. It works for me.
junit
cucumber-java
cucumber-junit
Make sure you are using the correct version of junit, cucumber-java, cucumber-junit. It should not be like you are using some older version of junit and latest versions of cucumber junit and java. I have list down the dependencies which I have used. You can try these.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.7.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.7.0</version>
</dependency>

The error simply says that cucumber is not configured properly on your device.
This can be because of missing dependencies or the dependencies are not loaded properly.
Check for the dependencies first and then save all, close the editor, and then reopen it.
Try to run again and check.

Removed Cucumber Core dependency from POM.XML it is working fine

Commenting in 2021. This might help someone.
The issues is simple, cucumber groupid has been changed to >io.cucumber< so if you are still using >info cukes< you will be getting exceptions. That is why when you update your cucumber java to the latest it solves the issue bc the latest groupid comes as io.cucumber. You can as well change all the groupid info cukes in your pom.xml to io.cucumber. This will solve the issue

<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
Keep only three tags (groupId, artifactId and version) in your dependencies. Delete <scope> and other additional tags in pom.xml and then try.

Errors on running Cucumber Feature
Exception in thread "main" cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
Solution
Most probably this means that your cucumber-java version and java version on your machine is not compatible with each other. First, check Java Version on your machine by going through this article How to check Java/JDK Version Installed on your Machine.
On my machine, I have Java 1.8.0 with cucumber-Java8-1.2.5 and it did not work. When I degraded my cucumber java version to cucumber-Java-1.2.5, it worked fine for me. Just make sure that first, you remove the cucumber-java which did not work for you from Project build path >> Libraries and then add new.

It can also be caused by having 2 backend: for example:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.8.0</version>
<scope>test</scope>
</dependency>
and
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
Also make sure you have compatible versions

I encountered this same error message when trying to run a Cucumber feature file in Eclipse ("No backends were found. Please make sure you have a backend module on your CLASSPATH").
What fixed it for me was going into my pom.xml and changing the cucumber-java and cucumber-junit versions away from 1.2.5 (per their documentation) to 1.2.0.
I'm not 100% sure if I'm ignoring a real issue by doing this or not. Here is more information about my setup:
Windows 10
Eclipse Neon (4.6.0)
Apache Maven 3.5.0
Java 1.8
I verified via quick commands that java and maven are installed successfully and running on my machine. I also verified that Maven pulled in the cucumber-java, and cucumber-core jars in my Eclipse project. Odd.

Adding the following dependency I got resolved this issue
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.6</version>
</dependency>

Related

Maven using wrong dependency version

The dependency version I want to use is 4.5.0 as specified in my pom.xml
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>4.5.0</version>
</dependency>
However, when I run mvn clean install -DskipTest=true. Maven will download and use version 4.2.2.
libraries
I tried searching in the entire project thinking maybe there are other files(in this case pom.xml) that specify the version to 4.2.2 but found nothing.
Has anybody encountered this issue before? I'm new to Java and I can't think of any other reason as to why this is happening.
Look at the output of mvn dependency:list. It will list you all dependencies of the project with their respective versions.
This is the truth. If your Eclipse or IntelliJ or whatever list something else, they are most certainly wrong/outdated.

Getting NoSuchMethodError:javax.servlet.ServletContext.getVirtualServerName()

I am facing an issue during deployment of a service in Tomcat 8. Getting following error :
Caused by: java.lang.NoSuchMethodError:
javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.tomcat.websocket.server.WsServerContainer.(WsServerContainer.java:149)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5244)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Method getVirtualServerName was introduced in Servlet 3.1 and after extracting MANIFEST.MF from my servlet-api jar I got following details :
Specification-Title: Java API for Servlets
Specification-Version: 3.1
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Which says that its having 3.1. So is there any other reason for this error? Please help
Check all your Maven (or equivalent) dependencies and make sure that you - or most likely another dependency - are not pulling in a pre-3.1 version of the javax.servlet / servlet-api that may be taking precedence over what's in your Tomcat 8. If you've manually deployed, make sure you haven't manually copied any servlet-api JARs into Tomcat itself.
See: https://stackoverflow.com/a/26232535/954442
The method getVirtualServerName has been added in ServletContext in Servlet 3.1. See the java doc's method getVirtualServerName.
This problem has 3 primary causes:
Your servlet version is older than 3.1.
Some other jar has the servlet with a version older than 3.1.
Your tomcat version is older than 8
to solve it, you can try the below way.
I. Check your pom.xml for the code below.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
if your pom.xml has the above code, it would still has that problem. you can do the second way.
II. to check your other jar has refer to the javax.servlet-api jar. for example, the org.apache.santuario has refer to the javax.servlet-api jar. the pom.xml:
<dependency>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>1.4.3</version>
</dependency>
but when you look at the maven dependencies, it refer to the javax.servlet-api jar whose version is 2.3 older than 3.1.
so you should exclude the 2.3 version. pom.xml:
<!-- exclude servlet-api 2.3 jar-->
<dependency>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>1.4.3</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- servlet-api 3.1 version has getVirtualServerName() -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
III. spring boot run the default tomcat 7. so define your tomcat version 8 instead of tomcat 7. so add the code your pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<tomcat.version>8.5.5</tomcat.version>
</properties>
I had this error on IntelliJ with maven after updating IntelliJ.
I could run the tests with maven but not from my IDE.
I solved the problem by removing the ./idea and project.iml files and reloading the project.
If you have used this dependency:
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
</dependency>
Then please exclude as below:
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
<exclusions>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
</exclusions>
</dependency>
Spring boot will run tomcat 7 per default, you have to override maven build tomcat.version in your pom.xml. See below to run tomcat 8.0.30
<properties>
<tomcat.version>8.0.30</tomcat.version>
</properties>
Should fix your problem.
Solved
On my mac with java 8 was facing issue with downloaded tomcat from site and unzip.
My issue got solved because there was a extra servlet-api.jar file which was getting picked up. It was coming from
/Library/Java/Extensions/servlet-api.jar
For finding it in your system you can use
sudo find / -name servlet-api.jar
Removed it by backing it up somewhere else.
I was following this for intallation
https://gist.github.com/ddanailov-nmdp/c97aba2ca926b9627f6b4f7174083a32
Assuming this problem appears when you ran the application in Eclipse.
Use Dependency Hierarchy view to search for servlet-api in pom.xm
After a huge pain & sifting through all these stackoverflow answers the only thing that ended up working for me was downgrading from tomcat8 to tomcat7. I know this isn't an ideal solution, and perhaps it was just a fresh install of tomcat that solved my problem. If all else fails give that a shot.
I attach gradle style dependencies code.
dependencies {
compileOnly("javax.servlet:javax.servlet-api:3.1.0")
This surely has something to do with the version of javax.servlet and version of Tomcat.
In my case, it went away when I declared javax.servlet dependency in gradle with no version. Like this -
compile('javax.servlet:servlet-api')

Eclipse: exclude a 'runtime' maven dependency from the build path

I have a project that needs a dependency on iText 5.5.2 and on iText 2.1.7 (Primefaces needs this specific version at runtime and won't work with iText 5 due to license issues).
So I have this in my pom.xml:
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.2</version>
<scope>compile</scope>
</dependency>
<!-- iText 2.1.7 is necessary at runtime to have the 'Export to PDF' function of Primeface work -->
<!-- It won't conflict with iText 5 as the packages are different -->
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<scope>runtime</scope>
</dependency>
The problem is that I don't want our developers to be able to import classes from iText 2.1.7 (com.lowagie.* package). I want to force them to use classes from iText 5.5.2 (com.itextpdf.* package).
Although iText 2.1.7 is in 'runtime' scope, Eclipse still adds the jar file in the build path, allowing developers to import the wrong package (com.lowagie instead of com.itextpdf).
Is there a way to exclude it from the build path ?
Unfortunately it seems not to be possible on Eclipse with a normal build, it is a known bug, check Bug 414645 and Bug 376616. Eclipse (m2e) can't properly manage Maven dependencies scope.
However, if you place the runtime dependencies on a profile, then Eclipse will not add them to the classpath (the profile shouldn't be active by default, though). I just tested it on Eclipse Mars and it works perfectly.
Hence, in your case you could add to your POM:
<profiles>
<profile>
<id>runtime</id>
<dependencies>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
As such, it can't be used to compile on Eclipse. However, your build would then need to use it at runtime, running with -Pruntime in this case.
Although adapting your POM and build to an issue of an IDE might not be ideal, it could be a good compromise to achieve your goal.

Compatibility issue between the 'groovy-all' jars present in eclipse plugin and maven dependency

In my POM, there is a dependency: spock-core 1.0-groovy-2.3, which adds groovy-all 2.3.10 to my project. And, my eclipse groovy plugin contains groovy-all 2.3.7 jar. So, whenever I try to run my groovy spec file, following error is thrown:
groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.7 and you are trying to load version 2.3.10
So, inorder to match the jars I am left with two options:
Downgrade the version of spock-core dependency
Upgrade eclipse plugin groovy-all jar to 2.3.10
First option is NOT possible as there is no such spock-core dependency which could provide me groovy-all 2.3.7 jar. So, please guide me as how I should upgrade my groovy eclipse plugin from 2.3.7 to 2.3.10.
P.S. I have set groovy compiler level as 2.3 for my project. And, I am facing the same issue on Luna, Kepler, Juno eclipse.
You can "downgrade" the Spock dependency. Simply add an exclude of "groovy-all" to your Spock dependency. Then explicitly add a dependency on groovy-all 2.3.7
The exclusion can be added as follows:
<dependency>
...
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
...
</dependency>
Update your POM file by adding the below maven repos:
<!-- Below 3 GROOVY dependencies are MUST to waive the version conflict in runtime
https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-xml -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>2.4.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>2.4.16</version>
</dependency>

Missing plugins found while loading a transformation on Kettle

I receive this error whenever I run my extraction from the command line, not in the Spoon UI.
Missing plugins found while loading a transformation
Step : MongoDbInput
at org.pentaho.di.job.entries.trans.JobEntryTrans.getTransMeta(JobEntryTrans.java:1200)
at org.pentaho.di.job.entries.trans.JobEntryTrans.execute(JobEntryTrans.java:643)
at org.pentaho.di.job.Job.execute(Job.java:714)
at org.pentaho.di.job.Job.execute(Job.java:856)
... 4 more
Caused by: org.pentaho.di.core.exception.KettleMissingPluginsException:
Missing plugins found while loading a transformation
My maven dependencies is as follows.
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libbase</artifactId>
<version>5.1.0.0-752</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-big-data-plugin</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-mongodb-plugin</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>metastore</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformula</artifactId>
</dependency>
<dependency>
<groupId>simple-jndi</groupId>
<artifactId>simple-jndi</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
Am I missing anything?
before init kettleEnviroment
KettleEnviroment.init();
you should add this code like
StepPluginType.getInstance().getPluginFolders().add(new PluginFolder("your plugins path", false, true));
Having the MongoDB plugin as a dependency only works for compilation. When PDI runs it looks for a plugins/ folder under the current directory, and will load all plugins from there. You can override the location by setting the KETTLE_PLUGIN_BASE_FOLDERS system property. Either way, you'll want a plugins/ folder and to unzip the MongoDB plugin package (not the JAR) into plugins/. That should put a folder called pentaho-mongodb-plugin under plugins/, and if PDI is pointing at that plugins/ folder, it should load and use the plugin successfully at runtime.
You must run Kitchen from Kettle installation directory.
As written here:
http://wiki.pentaho.com/display/EAI/Kitchen+User+Documentation
Please make sure that you are positioned in the Kettle directory
before running the samples below. If you put these scripts into a
batch file or shell script, simply do a change directory to the
installation directory
I had the same error message after an update from version 7 to 8.3. In my case, it was the step 'Abort' and 'Attend' that caused the error. In version 8 these two steps aren't part of the library "kettle-engine-8.3.0.0-371.jar" anymore, they are now part of the library "pdi-core-plugins-impl-8.3.0.0-371.jar" in a new plugin. I had to add the plugin in the maven-dependencies:
<dependency>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>pdi-core-plugins-impl</artifactId>
<version>8.3.0.0-371</version>
</dependency>
But that was still not everything, I still got the error message. The reason: "To use non-native plugins with an embedded Pentaho Server, you must configure the server to find where the plugins reside" (https://help.hitachivantara.com/Documentation/Pentaho/8.0/Developer_Center/PDI/Embed).
So above the line KettleEnvironment.init() in my java-code, I added this one:
System.setProperty("KETTLE_PLUGIN_CLASSES", "org.pentaho.di.trans.steps.abort.AbortMeta,org.pentaho.di.trans.steps.append.AppendMeta");
KettleEnvironment.init();
This way worked for me. There's also a suggestion using a plugin-folder (see the link or the other answers) and working with KETTLE_PLUGIN_BASE_FOLDER instead.
Unfortunately, the error message doesn't mention which plugin is missing. I deleted and added them (in my local Spoon application) until I found exactly the one that was missing.
Just edit spoon.sh and add
OPT="$OPT -DKETTLE_PLUGIN_BASE_FOLDERS=$BASEDIR/plugins"
right after the line where the OPT variable is set.
This is actually the solution from mattyb. Editing spoon.sh will fix the problem for good.
Another solution is to create a symbolic link in your ${KETTLE_HOME}/.kettle directory which points to the plugins folder.

Categories

Resources