Skip to content

[🐛 Bug]: java.lang.NoClassDefFoundError: org/openqa/selenium/remote/mobile/RemoteNetworkConnection #15382

@Mr-LiuDC

Description

@Mr-LiuDC

What happened?

org/openqa/selenium/remote/mobile/RemoteNetworkConnection
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/mobile/RemoteNetworkConnection

build.gradle

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.4.2'
    id 'io.spring.dependency-management' version '1.1.7'
}

group = 'pub.itpark.example'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    maven { url = 'https://maven.aliyun.com/repository/public' }
    maven { url = 'https://repo.spring.io/milestone' }
    maven { url = 'https://jitpack.io' }
    mavenCentral()
}

ext {
    sentryVersion = "8.1.0"
    springAiVersion = "1.0.0-M5"
    springCloudVersion = "2024.0.0"
    saTokenVersion = "1.40.0"
    hibernateUtilsVersion = '3.7.5'
    springDocVersion = '2.8.4'
    knife4jVersion = '4.5.0'
    hutoolVersion = '5.8.35'
    jjwtVersion = "0.12.5"
    webjarsLocatorVersion = '0.52'
    bootstrapVersion = '5.3.3'
    jqueryVersion = '3.7.1'
    webmagicVersion = '1.0.3'
    seleniumJavaVersion = '4.29.0'
    webdrivermanagerVersion = '5.9.3'
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-data-redis'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation "cn.hutool:hutool-all:${hutoolVersion}"
    implementation "us.codecraft:webmagic-extension:${webmagicVersion}"
    implementation "org.seleniumhq.selenium:selenium-java:${seleniumJavaVersion}"
    implementation "org.seleniumhq.selenium:selenium-support:${seleniumJavaVersion}"
    implementation "org.seleniumhq.selenium:htmlunit3-driver:${seleniumJavaVersion}"
    implementation "org.seleniumhq.selenium:selenium-edge-driver:${seleniumJavaVersion}"
    implementation "org.seleniumhq.selenium:selenium-chrome-driver:${seleniumJavaVersion}"
    implementation "org.seleniumhq.selenium:selenium-remote-driver:${seleniumJavaVersion}"
    implementation "io.github.bonigarcia:webdrivermanager:${webdrivermanagerVersion}"
    implementation "io.hypersistence:hypersistence-utils-hibernate-63:${hibernateUtilsVersion}"

    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'com.h2database:h2'
    runtimeOnly 'com.mysql:mysql-connector-j'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
    imports {
        mavenBom "io.sentry:sentry-bom:${sentryVersion}"
        mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}"
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

springBoot {
    buildInfo()
}

test {
    useJUnitPlatform()
}

How can we reproduce the issue?

Example code:

package pub.itpark.spider.selenium;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

/**
 * @author LDC
 */
public class ChromeDriverTest {

    @Test
    public void testChromeDriver() {
        WebDriverManager
                .chromedriver()
                .setup();

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--headless");
        options.addArguments("--disable-gpu");

        WebDriver driver = new ChromeDriver(options);
        driver.get("https://google.baidu.com");
        System.out.println(driver.getTitle());
        driver.quit();
    }

}



package pub.itpark.spider.selenium;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

/**
 * @author LDC
 */
public class EdgeDriverTest {

    @Test
    public void testEdgeDriver() {
        WebDriverManager.edgedriver().setup();

        EdgeOptions options = new EdgeOptions();
        options.addArguments("--headless");
        options.addArguments("--disable-gpu");

        WebDriver driver = new EdgeDriver(options);
        driver.get("https://google.baidu.com");
        System.out.println(driver.getTitle());
        driver.quit();
    }

}

Relevant log output

Logs:

09:32:55.296 [Test worker] INFO io.github.bonigarcia.wdm.WebDriverManager -- Using chromedriver 134.0.6998.35 (resolved driver for Chrome 134)
09:32:55.357 [Test worker] INFO io.github.bonigarcia.wdm.WebDriverManager -- Exporting webdriver.chrome.driver as C:\Users\aipark\.cache\selenium\chromedriver\win64\134.0.6998.35\chromedriver.exe

org/openqa/selenium/remote/mobile/RemoteNetworkConnection
java.lang.NoClassDefFoundError: org/openqa/selenium/remote/mobile/RemoteNetworkConnection
	at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:118)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72)
	at pub.itpark.spider.selenium.ChromeDriverTest.testChromeDriver(ChromeDriverTest.java:26)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.mobile.RemoteNetworkConnection
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 8 more

Operating System

Windows 10

Selenium version

4.29.0

What are the browser(s) and version(s) where you see this issue?

Chrome 134,Edge 133

What are the browser driver(s) and version(s) where you see this issue?

chromedriver 134.0.6998.35,msedgedriver 133.0.3065.92

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions