Reputation: 81
I am getting this stack trace when running a very basic feature which just opens a browser, navigates to google.com and search some string.
Exception in thread "main" java.lang.NoClassDefFoundError:
org/springframework/transaction/TransactionStatus
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:40)
at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:86)
at cucumber.runtime.Runtime.<init>(Runtime.java:92)
at cucumber.runtime.Runtime.<init>(Runtime.java:70)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException:
org.springframework.transaction.TransactionStatus
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 11 more
Can someone tell me what is missing here?
Upvotes: 8
Views: 5774
Reputation: 61
The below dependency is missing. Default glue cucumber.api.spring
is not able to find class transaction so it throws an error. Add dependency to your pom.xml
and it will solve your issue
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
Upvotes: 6
Reputation: 59
You should switch The Run configuration to 'com.foreach.cuke'
instead of 'cucumber.api.spring'..
Go to 'Edit Configurations'
- 'Cucumber'
- Glue: com.foreach.cuke
...
Upvotes: 3
Reputation: 223
For Intellij 2018.1 and i guess for early versions, the Run configuration by default gets the Glue 'cucumber.api.spring' , you should switch it for 'com.foreach.cuke'
Go to 'Edit Configurations' - 'Cucumber' - Glue: com.foreach.cuke ...
Upvotes: 11
Reputation: 193088
As far as NoClassDefFoundError
is concerned, it arises due to mismatch between the following components :
JDK
version - Solution
- Keep the JDK
version updated to the recent releases.JUnit
version - Solution
- Keep the JUnit
version in sync with cucumber
version.Selenium
version - Solution
- Update the Selenium
version to the recent release versions.WebDriver Binary
version - Solution
- Update the WebDriver
version to the recent release versions.Web Browser Binary
version - Solution
- Update the Web Browser
version to the recent release versions.Upvotes: 0