[🐛 Bug]: IllegalAccessError with Selenium 4.5.0 when attempting to run Chrome in Java Module System
See original GitHub issueWhat happened?
java.lang.IllegalAccessError: class org.openqa.selenium.remote.service.DriverService (in module org.seleniumhq.selenium.remote_driver) cannot access class org.openqa.selenium.internal.Require (in module org.seleniumhq.selenium.api) because module org.seleniumhq.selenium.api does not export org.openqa.selenium.internal to module org.seleniumhq.selenium.remote_driver
How can we reproduce the issue?
Steps to reproduce
Require Java 17, latest version
Require a multi module Java project
For example, create a Java module, called module-a. Create a Java test module called module-a-test
In module-a-test require module-a as well as the Selenium requirements
Verify each module has a module-info.java file in the same directory as the java directory
Run a JUnit test that creates a new ChromeDriver from within module-a-test
Chrome browser will start, chromedriver will start, however, shortly afterwards, this error will be encountered
Alternatively, I think if you add module-info.java to an existing project in the java directory, this should also reproduce the error.
Relevant log output
java.lang.IllegalAccessError: class org.openqa.selenium.remote.service.DriverService (in module org.seleniumhq.selenium.remote_driver) cannot access class org.openqa.selenium.internal.Require (in module org.seleniumhq.selenium.api) because module org.seleniumhq.selenium.api does not export org.openqa.selenium.internal to module org.seleniumhq.selenium.remote_driver
at org.seleniumhq.selenium.remote_driver/org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:135)
at org.seleniumhq.selenium.chrome_driver/org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:39)
at org.seleniumhq.selenium.chrome_driver/org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:233)
at org.seleniumhq.selenium.remote_driver/org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:437)
at org.seleniumhq.selenium.chrome_driver/org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:128)
at org.seleniumhq.selenium.chrome_driver/org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:49)
at module.a.test/xyz.repro.application.tests.ApplicationTests.startChromeInJavaModuleSystemTest(ApplicationTests.java:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.platform.commons@1.9.0/org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
at org.junit.jupiter.engine@5.9.0/org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine@1.9.0/org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
Operating System
Windows 10
Selenium version
4.5.0
What are the browser(s) and version(s) where you see this issue?
Chrome 106
What are the browser driver(s) and version(s) where you see this issue?
chromedriver.exe 106.0.5249.61
Are you using Selenium Grid?
No
Issue Analytics
- State:
- Created a year ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
illegalAccessError while using chromedriver with selenium
I am getting IllegalAccessError while using chromedriver in selenium. I have added chromedriver.exe to my path, and also set it in java code....
Read more >Upgrade to Selenium 4
Are you still using Selenium 3? This guide will help you upgrade to the latest release!
Read more >[ERROR] Failed to execute goal org.springframework.boot:spring ...
Answers related to “[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.1.RELEASE:run”.
Read more >Open Browser Stopped Working After Update and Create ...
1 - Using Open Browser keyword results in a chrome crash failure: WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (unknown ......
Read more >Security update for roundcubemail (Moderate) - Support
(bsc#937766) It also fixes the following non-security bugs: ... Security update for Chromium (Important) openSUSE 13.1 Chromium was updated ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

https://github.com/SeleniumHQ/selenium/commit/c927a5b65bbaa3dede337e50e34ed3aadd803db8 this is the commit that caused the error. The commit is doing the right thing. However, based on my understanding what needs to change is https://github.com/SeleniumHQ/selenium/blob/c22de96c68712c1fbbf621a6d3de438eee69d1b1/java/src/org/openqa/selenium/BUILD.bazel#L26. We should not be hiding internal package. I am going to test the change locally and see if this solves it tomorrow.
Thank you for digging into this. The two commits ideally should not impact how the exports are done. But I will need to take a look to if it has impacted this issue and maybe caused other issues.