Geb Exception: java.lang.NoClassDefFoundError: geb/error/GebException - geb

IDE is Configured to use:
java: 7
geb: 0.9.1
Selenium java client and web driver: 2.35
When running the simple groovy script:
import geb.Browser
def browser = new Browser()
I get the following error:
Caught: java.lang.NoClassDefFoundError: geb/error/GebException
java.lang.NoClassDefFoundError: geb/error/GebException
at dave.run(dave.groovy:12)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: geb.error.GebException
... 2 more
Everything compiles just fine and according to every document available, I should be okay.
Any ideas?

Case Closed!
According to http://mvnrepository.com/artifact/org.gebish/geb-core/0.9.1, namely the "This artifact depends on ..." section, I needed some more dependencies.

Related

Error while using JUnit5 with spring boot 2

I am getting following error while running JUnit5 with SpringBoot.
Here is the stack trace that I get when I run
./gradlew clean test
:junitPlatformTest
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil
at org.apache.logging.log4j.jul.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:34)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.log4j.jul.LogManager.getLogger(LogManager.java:89)
at java.util.logging.LogManager.demandLogger(LogManager.java:551)
at java.util.logging.Logger.demandLogger(Logger.java:455)
at java.util.logging.Logger.getLogger(Logger.java:502)
at org.junit.platform.commons.logging.LoggerFactory$DelegatingLogger.<init>(LoggerFactory.java:62)
at org.junit.platform.commons.logging.LoggerFactory.getLogger(LoggerFactory.java:49)
at org.junit.platform.launcher.core.DefaultLauncher.<clinit>(DefaultLauncher.java:44)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:59)
at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:61)
at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:85)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:75)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:48)
at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:40)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.ReflectionUtil
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)
... 18 more
The github url for above code is github link
This is caused by mixing different versions of Log4J on the test runtime classpath. Spring Boot pulls in 2.10.0, your build.gradle declares 2.6.2.
If you remove the version from your dependency definition, Spring Boot will define the version and it will work.
So, please replace these two lines
testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")
with these:
testRuntime("org.apache.logging.log4j:log4j-core")
testRuntime("org.apache.logging.log4j:log4j-jul")
Alternatively, you can delete the logManager property from the junitPlatform extension and remove both dependencies.

Selenium - Java : PhantomJS : Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.HttpVerb

I am trying to instantiate a PhantomJS Driver with Selenium Java. Below is the code :
File file = new File("C:\\Softwares\\drivers\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty("phantomjs.binary.path", file.getAbsolutePath());
WebDriver driver = new PhantomJSDriver();
driver.get("http://www.google.com");
I have tried with different versions of Selenium and I am getting the same exception :
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.HttpVerb
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/HttpVerb
at org.openqa.selenium.phantomjs.PhantomJSDriver.getCustomCommands(PhantomJSDriver.java:166)
at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.<init>(PhantomJSCommandExecutor.java:62)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:110)
I'm using the below list of dependencies in my project :
phantomjsdriver
selenium-common.jar
selenium-java 2.53.1 . jar
The reason I'm using an outdated version of selenium library is due to some article I found over the internet saying that remote/HttpVerb is deprecated and downgrading the library would remove the error. However, I'm still getting this error
Please check this dependancy in POM
<dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-remote-driver</artifactId>
      <version>2.53.1</version>
    </dependency>
Check whether this class is present or not

ClassNotFoundException when trying to execute a jar file in serenity-jbehave

I'm getting the error below:
Exception in thread "main"java.lang.NoClassDefFoundError:net/serenitybdd/jbehave/SerenityStories
Caused by: java.lang.ClassNotFoundException: net.serenitybdd.jbehave.SerenityStories
That's a dependency conflict. Check that you are using the latest versions for all of the serenity jars.

Exception by using SafariDriver

I'm trying to run selenium safari driver.
My code is: driver = new SafariDriver();
But I get the following exception:
Caused by: java.lang.NoClassDefFoundError: org/jboss/netty/channel/ChannelFactory
at org.openqa.selenium.safari.SafariDriverCommandExecutor.<init>(SafariDriverCommandExecutor.java:76)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:58)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:42)
at com.ca.automation.utils.WebDriverFactory.initWebDriver(WebDriverFactory.java:168)
at com.ca.automation.utils.WebDriverFactory.getWebDriver(WebDriverFactory.java:210)
at com.ca.automation.utils.BaseSelenium.<init>(BaseSelenium.java:43)
at com.ca.automation.pb.strategicPlanning.CrudDriversBTest.<init>(CrudDriversBTest.java:20)
There could be a solution: Selenium 2 WebDriver NoClassDefFoundErrorS. You just need to use the standalone version or add all the jars to the build path.

(java)Could not find the main class

My code is compiled on OSX and it works fine(compiler version 1.6). But when I copy it to a remote ubuntu. I can not run it.
When I run
java TPCC.class
I got exception like this.(By the way TPCC.class is in default package)
Exception in thread "main" java.lang.NoClassDefFoundError: TPCC/class
Caused by: java.lang.ClassNotFoundException: TPCC.class
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: TPCC.class. Program will exit.
And my java version on ubuntu:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)
It's also 1.6 and I think it fits the compiled binary. How can I fix this problem?
The problem is in the way you run the program. Compiled java called
ClassName.java
will be ClassName.class. You should run it like
"java ClassName"
. You shouldn't run it as
"java ClassName.class"
What happens here is this. When you run it as java ClassName.class, JVM try to look for ClassName called "class" in the package called "ClassName" that does not exist. So it will throw NoClassDefFoundError.
This is an invocation problem as the error shows: java should be used and not the filename of the class.
The error message tries to say you this by stating that "TPCC/class" is not found.
(sorry for first adding comment, used the wrong field)
Specify the classpath when invoking java:
java -cp <path-to-jar> TPCC