Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: org/openqa/selenium/devtools/HasDevTools #2722

Closed
ghost opened this issue Feb 21, 2022 · 4 comments
Closed

Comments

@ghost
Copy link

ghost commented Feb 21, 2022

I'm getting this error with every version of serenity after 3.1.15

Issue #2664 says "project is pulling in Selenium 3, whereas Serenity (and DevTools) needs Selenium 4"
It appears it's the serenity-core library that's bringing in selenium 3 libraries.
I can workaround this issue either by adding the selenium-devtools library, or by reverting the net.serenity-bdd libraries to 3.1.15

Note: same error occurs when using net.serenity-bdd version 3.2.0

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.6.3</version>
</parent>

<properties>
	<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
	<java.version>11</java.version>

	<maven.compiler.source>${java.version}</maven.compiler.source>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<maven.compiler.target>${java.version}</maven.compiler.target>

	<!-- Spring WebClient -->
	<reactor-spring.version>1.0.1.RELEASE</reactor-spring.version>

	<!-- Spring Vault -->
	<spring-vault-core.version>2.3.2</spring-vault-core.version>

	<!-- Serenity -->
	<serenity-core.version>3.1.16</serenity-core.version>

	<!-- Utilities -->
	<guava.version>31.0.1-jre</guava.version>

</properties>

<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-configuration-processor</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
	</dependency>

	<!-- Spring WebClient -->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-webflux</artifactId>
	</dependency>
	<dependency>
		<groupId>org.projectreactor</groupId>
		<artifactId>reactor-spring</artifactId>
		<version>${reactor-spring.version}</version>
	</dependency>

	<!-- Spring Vault -->
	<dependency>
		<groupId>org.springframework.vault</groupId>
		<artifactId>spring-vault-core</artifactId>
		<version>${spring-vault-core.version}</version>
	</dependency>

	<!-- Serenity -->
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-core</artifactId>
		<version>${serenity-core.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-junit</artifactId>
		<version>${serenity-core.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-spring</artifactId>
		<version>${serenity-core.version}</version>
	</dependency>
	<dependency>
		<groupId>org.junit.vintage</groupId>
		<artifactId>junit-vintage-engine</artifactId>
		<scope>test</scope>
		<exclusions>
			<exclusion>
				<groupId>org.hamcrest</groupId>
				<artifactId>hamcrest-core</artifactId>
			</exclusion>
		</exclusions>
	</dependency>

	<dependency>
		<groupId>io.rest-assured</groupId>
		<artifactId>rest-assured</artifactId>
	</dependency>

	<!-- Utilities -->
	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
	</dependency>
	<dependency>
		<groupId>com.google.guava</groupId>
		<artifactId>guava</artifactId>
		<version>${guava.version}</version>
	</dependency>

</dependencies>

java.lang.NoClassDefFoundError: org/openqa/selenium/devtools/HasDevTools
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at net.thucydides.core.steps.BaseStepListener.(BaseStepListener.java:356)
at net.thucydides.core.steps.BaseStepListener.(BaseStepListener.java:352)
at net.thucydides.core.steps.Listeners$BaseStepListenerBuilder.withOutputDirectory(Listeners.java:37)
at net.thucydides.junit.listeners.JUnitStepListenerBuilder.buildBaseStepListener(JUnitStepListenerBuilder.java:90)
at net.thucydides.junit.listeners.JUnitStepListenerBuilder.newStandardJunitStepListener(JUnitStepListenerBuilder.java:110)
at net.thucydides.junit.listeners.JUnitStepListenerBuilder.build(JUnitStepListenerBuilder.java:79)
at net.serenitybdd.junit.runners.SerenityRunner.initListeners(SerenityRunner.java:376)
at net.serenitybdd.junit.runners.SerenityRunner.buildAndConfigureListeners(SerenityRunner.java:342)
at net.serenitybdd.junit.runners.SerenityRunner.getStepListener(SerenityRunner.java:323)
at net.serenitybdd.junit.runners.SerenityRunner.initializeRunNotifier(SerenityRunner.java:347)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:247)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.devtools.HasDevTools
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)

@wakaleo
Copy link
Member

wakaleo commented Feb 21, 2022

Dependency conflicts, probably from SpringBoot

@ghost
Copy link
Author

ghost commented Feb 21, 2022

Perhaps, but what's conflicting with what? If I make this change, it works:
<serenity-core.version>3.1.15</serenity-core.version>
With the same version of spring boot

From my perspective, the conflict was introduced by version 3.1.16.
Something in the 3.1.16 libraries is looking for HasDevTools, which isn't included in the 3.1.16 package.

@wakaleo
Copy link
Member

wakaleo commented Feb 21, 2022

Yes, that version introduced support for Selenium 4 DevTools.

@ghost
Copy link
Author

ghost commented Feb 21, 2022

For others who encounter this, appears both org.springframework.boot:spring-boot-dependencies and net.serenity-bdd:serenity-bdd try to set the selenium.version. I got this error because spring is setting and older version, and it overrode serenity's setting.

Open the net.serenity-bdd:serenity-bdd POM for the version of serenity you are using. Copy the <selenium.version> from the properties to the properties of your POM. For serenity 3.2.0, it's <selenium.version>4.1.2</selenium.version>

@ghost ghost closed this as completed Feb 21, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant