java.lang.IllegalAccessError:试图访问方法 com.google.common.util.concurrent.SimpleTimeLimiter.使用 Selenium-Java 3.5.1 或更高版本时

我想知道是否有人可以告诉我为什么在使用 Selenium-Java 3.5.1 或更高版本时出现以下错误 -

java.lang.IllegalAccessError: 试图从类 org.openqa.selenium 访问方法 com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V.net.UrlChecker

解决方案

这个错误信息...

java.lang.IllegalAccessError: 试图从类 org.openqa.selenium 访问方法 com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V.net.UrlChecker

...暗示 WebDriver 变体的版本(即 GeckoDriver/ChromeDriver)与您正在使用的相应 WebBrowser 变体(即 Firefox/Chrome).

<块引用>

注意:您需要确保您使用的是最新的


ChromeDriver-Chrome

如果您使用的是 ChromeDriver-Chrome 组合,则需要根据以下条目确保二进制文件兼容:

  • ChromeDriver v84:支持 Chrome v84
  • ChromeDriver v83:支持 Chrome v83
  • ChromeDriver v82:被故意跳过
  • ChromeDriver v81:支持 Chrome v81
  • ChromeDriver v80:支持 Chrome v80
  • ChromeDriver v79:支持 Chrome v79
  • ChromeDriver v78:支持 Chrome v78
  • ChromeDriver v77:支持 Chrome v77
  • ChromeDriver v76:支持 Chrome v76
  • ChromeDriver v75:支持 Chrome v75
  • ChromeDriver v74:支持 Chrome v74
  • ChromeDriver v73:支持 Chrome v73
  • ChromeDriver v2.46:支持 Chrome v71-73
  • ChromeDriver v2.45:支持 Chrome v70-72
  • ChromeDriver v2.44:支持 Chrome v69-71(与 ChromeDriver 2.43 相同,但修复了其他错误)
  • ChromeDriver v2.43:支持 Chrome v69-71
  • ChromeDriver v2.42:支持 Chrome v68-70
  • ChromeDriver v2.41:支持 Chrome v67-69
  • ChromeDriver v2.40:支持 Chrome v66-68
  • ChromeDriver v2.39:支持 Chrome v66-68
  • ChromeDriver v2.38:支持 Chrome v65-67
  • ChromeDriver v2.37:支持 Chrome v64-66
  • ChromeDriver v2.36:支持 Chrome v63-65
  • ChromeDriver v2.35:支持 Chrome v62-64
  • ChromeDriver v2.34:支持 Chrome v61-63
  • ChromeDriver v2.33:支持 Chrome v60-62
  • ChromeDriver v2.32:支持 Chrome v59-61
  • ChromeDriver v2.31:支持 Chrome v58-60
  • ChromeDriver v2.30:支持 Chrome v58-60
  • ChromeDriver v2.29:支持 Chrome v56-58
  • ChromeDriver v2.28:支持 Chrome v55-57
  • ChromeDriver v2.27:支持 Chrome v54-56
<块引用>

注意:几个月前,Chromium 团队做了一个 初步公告 ChromeDriver 的版本控制模型将发生变化.现在Chromium 团队 正在推进该计划.具体来说,ChromeDriver 2.46 将是最后一个带有 2 主要版本的版本.未来的 ChromeDriver 版本将带有类似于 Chrome 版本的版本号.我们将在下周发布 ChromeDriver 73,在 Chrome 73 的 Beta 版之前发布.

以下是新发布模型的工作方式:

  • ChromeDriver 将使用与 Chrome 相同的版本号方案.请参阅 https://www.chromium.org/developers/version-numbers 了解更多信息详情.
  • ChromeDriver 的每个版本都将支持具有匹配的主要、次要和内部版本号的 Chrome.例如,即将推出的 ChromeDriver 73.0.3683.* 将支持以 73.0.3683 开头的所有 Chrome 版本.
  • 在新的 Chrome 主要版本进入 Beta 版之前,将发布一个匹配的 ChromeDriver 版本.例如,下周将发布新版本的 ChromeDriver,以匹配 Chrome m73 的 Beta 版本.
  • 在新的主要版本首次发布后,我们将根据需要发布补丁.这些补丁可能与 Chrome 的更新一致,也可能不一致.

此外,当 Selenum 网格节点 似乎已成功注册到 时,也会观察到此错误 com.google.common.util.concurrent.SimpleTimeLimiterSelenum Grid Hub 并且也从网格控制台得到确认,但是在请求会话时观察到以下错误:

org.openqa.selenium.WebDriverException: com.google.common.util.concurrent.SimpleTimeLimiter.create(Ljava/util/concurrent/ExecutorService;)Lcom/google/common/util/concurrent/SimpleTimeLimiter;

Selenium-Grid-Extras Hub (1.12.16) 发生此错误是因为 打包到 JAR 中的 selenium 和 guava 依赖项之间存在不一致

此问题已通过合并 #367 和使用解决Selenium v​​3.8.1 将解决您的问题.

确保两点为:

  • Selenium Grid Extras 版本大于(或等于)1.12.17
  • guava 依赖项已更新.

I am wondering if anyone can give me an idea why I'm getting the following error when I use Selenium-Java 3.5.1 or above -

java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker

解决方案

This error message...

java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker

...implies that there was a mismatch between the version of the WebDriver variant (i.e. GeckoDriver / ChromeDriver) and the version of the respective WebBrowser variant (i.e. Firefox / Chrome) you are using.

Note: You need to ensure that you are using the latest JDK versions.


GeckoDriver-Selenium-Firefox

If you are using GeckoDriver-Selenium-Firefox combo, you need to follow the following compatibility chart:


ChromeDriver-Chrome

If you are using ChromeDriver-Chrome combo, you need to ensure that the binaries are compatible as per the entries below:

  • ChromeDriver v84: Supports Chrome v84
  • ChromeDriver v83: Supports Chrome v83
  • ChromeDriver v82: Was intentionally skipped
  • ChromeDriver v81: Supports Chrome v81
  • ChromeDriver v80: Supports Chrome v80
  • ChromeDriver v79: Supports Chrome v79
  • ChromeDriver v78: Supports Chrome v78
  • ChromeDriver v77: Supports Chrome v77
  • ChromeDriver v76: Supports Chrome v76
  • ChromeDriver v75: Supports Chrome v75
  • ChromeDriver v74: Supports Chrome v74
  • ChromeDriver v73: Supports Chrome v73
  • ChromeDriver v2.46: Supports Chrome v71-73
  • ChromeDriver v2.45: Supports Chrome v70-72
  • ChromeDriver v2.44: Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes)
  • ChromeDriver v2.43: Supports Chrome v69-71
  • ChromeDriver v2.42: Supports Chrome v68-70
  • ChromeDriver v2.41: Supports Chrome v67-69
  • ChromeDriver v2.40: Supports Chrome v66-68
  • ChromeDriver v2.39: Supports Chrome v66-68
  • ChromeDriver v2.38: Supports Chrome v65-67
  • ChromeDriver v2.37: Supports Chrome v64-66
  • ChromeDriver v2.36: Supports Chrome v63-65
  • ChromeDriver v2.35: Supports Chrome v62-64
  • ChromeDriver v2.34: Supports Chrome v61-63
  • ChromeDriver v2.33: Supports Chrome v60-62
  • ChromeDriver v2.32: Supports Chrome v59-61
  • ChromeDriver v2.31: Supports Chrome v58-60
  • ChromeDriver v2.30: Supports Chrome v58-60
  • ChromeDriver v2.29: Supports Chrome v56-58
  • ChromeDriver v2.28: Supports Chrome v55-57
  • ChromeDriver v2.27: Supports Chrome v54-56

Note: A few months ago, Chromium Team made a preliminary announcement that ChromeDriver's versioning model will be changing. Now Chromium Team is moving forward with the plan. Specifically, ChromeDriver 2.46 will be the last release carrying the major version of 2. Future ChromeDriver releases will carry a version number similar to Chrome release. We will start with a release of ChromeDriver 73 next week, before the Beta release of Chrome 73.

Here is how the new release model will work:

  • ChromeDriver will be using the same version number scheme as Chrome. See https://www.chromium.org/developers/version-numbers for more details.
  • Each version of ChromeDriver will support Chrome with matching major, minor, and build version numbers. For example, upcoming ChromeDriver 73.0.3683.* will support all Chrome versions that start with 73.0.3683.
  • Before a new major version of Chrome goes to Beta, a matching version of ChromeDriver will be released. For example, a new version of ChromeDriver will be release next week to match the Beta release of Chrome m73.
  • After the initial release of a new major version, we will release patches as needed. These patches may or may not coincide with updates to Chrome.

Further, this error com.google.common.util.concurrent.SimpleTimeLimiter was also observed when a Selenum Grid Node appears to have successfully registered to the Selenum Grid Hub and was also confirmed from the grid console but when requesting for a session the following error was observed :

org.openqa.selenium.WebDriverException: com.google.common.util.concurrent.SimpleTimeLimiter.create(Ljava/util/concurrent/ExecutorService;)Lcom/google/common/util/concurrent/SimpleTimeLimiter;

This error occured with Selenium-Grid-Extras Hub (1.12.16) due to inconsistency between selenium and guava dependencies that are packaged into the JAR

This issue was addressed through the merge #367 and using Selenium v3.8.1 will solve your problem.

Ensure two points as :

  • Selenium Grid Extras version is greater than (or equal to) 1.12.17
  • guava dependencies are updated.

相关文章