java.lang.illegalaccesserror:尝试访问方法com.google.common.util.concurrent.simpletimelimiter使用maven

发布于 2025-01-21 06:12:18 字数 4991 浏览 0 评论 0 原文

运行脚本时,我会收到以下错误:

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

以下是我的pom.xml,

  <properties>
    <entry_point>**/*Suite.java</entry_point>
    <serenity.version>1.1.39</serenity.version>
    <serenity.jbehave.version>1.9.0</serenity.jbehave.version>
    <webdriver.driver>chrome</webdriver.driver>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-rest-assured</artifactId>
      <version>2.2.9</version>
    </dependency>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-jbehave</artifactId>
      <version>${serenity.jbehave.version}</version>
    </dependency>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-core</artifactId>
      <version>${serenity.version}</version>
    </dependency>
    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-util</artifactId>
      <version>1.1.6</version>
    </dependency>
    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-assert</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.7</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.18</version>
        <configuration>
          <includes>
            <include>${entry_point}</include>
          </includes>
          <runOrder>alphabetical</runOrder>
            <systemPropertyVariables>
            <metafilter>-productionOnly</metafilter>
            <chrome.switches>--no-sandbox,--disable-extensions</chrome.switches>
            <webdriver.driver>${webdriver.driver}</webdriver.driver>
            <serenity.data.dir>..</serenity.data.dir>
            <serenity.step.delay>0</serenity.step.delay>
            <serenity.take.screenshots>FOR_FAILURES</serenity.take.screenshots>
            <serenity.driver.capabilities>
          unexpectedAlertBehaviour:ignore;ie.ensureCleanSession=true; 
            </serenity.driver.capabilities>
            <story.timeout.in.secs>1800</story.timeout.in.secs>
            <use.test.case.for.story.tag>false</use.test.case.for.story.tag>
            <untrusted.certificates>false</untrusted.certificates>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.serenity-bdd.maven.plugins</groupId>
        <artifactId>serenity-maven-plugin</artifactId>
        <version>${serenity.version}</version>
        <executions>
          <execution>
            <id>serenity-reports</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>aggregate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

我尝试过更新Chromedriver和Serenity依赖性,但这并不能解决问题。谁能帮助我为此找到解决方案?

When running my scripts, I get the following error:

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

Below is my pom.xml

  <properties>
    <entry_point>**/*Suite.java</entry_point>
    <serenity.version>1.1.39</serenity.version>
    <serenity.jbehave.version>1.9.0</serenity.jbehave.version>
    <webdriver.driver>chrome</webdriver.driver>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-rest-assured</artifactId>
      <version>2.2.9</version>
    </dependency>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-jbehave</artifactId>
      <version>${serenity.jbehave.version}</version>
    </dependency>
    <dependency>
      <groupId>net.serenity-bdd</groupId>
      <artifactId>serenity-core</artifactId>
      <version>${serenity.version}</version>
    </dependency>
    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-util</artifactId>
      <version>1.1.6</version>
    </dependency>
    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-assert</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.7</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.18</version>
        <configuration>
          <includes>
            <include>${entry_point}</include>
          </includes>
          <runOrder>alphabetical</runOrder>
            <systemPropertyVariables>
            <metafilter>-productionOnly</metafilter>
            <chrome.switches>--no-sandbox,--disable-extensions</chrome.switches>
            <webdriver.driver>${webdriver.driver}</webdriver.driver>
            <serenity.data.dir>..</serenity.data.dir>
            <serenity.step.delay>0</serenity.step.delay>
            <serenity.take.screenshots>FOR_FAILURES</serenity.take.screenshots>
            <serenity.driver.capabilities>
          unexpectedAlertBehaviour:ignore;ie.ensureCleanSession=true; 
            </serenity.driver.capabilities>
            <story.timeout.in.secs>1800</story.timeout.in.secs>
            <use.test.case.for.story.tag>false</use.test.case.for.story.tag>
            <untrusted.certificates>false</untrusted.certificates>
          </systemPropertyVariables>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.serenity-bdd.maven.plugins</groupId>
        <artifactId>serenity-maven-plugin</artifactId>
        <version>${serenity.version}</version>
        <executions>
          <execution>
            <id>serenity-reports</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>aggregate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

I have tried updated the chromedriver and the serenity dependencies but that did not resolve the issue. Can anyone help me figure a solution for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初熏 2025-01-28 06:12:18

错误表明您正在使用的WebDriver变体(即Geckodriver / Chromedriver)的版本之间存在不匹配。

确保您使用的是最新的JDK版本,如果没有,请更新您的JDK,然后重试。这可能会有所帮助。

The error indicated 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.

Make Sure you are using latest JDK version, if not then update your JDK and try again. That may help.
https://www.oracle.com/technetwork/java/javase/downloads/index.html

听闻余生 2025-01-28 06:12:18

此错误消息...

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

...意味着您正在使用的二进制文件之间存在一些不兼容


解决方案

确保将 jdk 升级到当前级别 JDK 8U311
INCASE您正在使用 Chromedriver / Chrome 组合,请确保:


参考文献

您可以在: java.lang.illang.illegalaccesserror中找到一些相关的详细讨论

  • :尝试访问方法com.google.common.util。并发。使用硒 - 贾瓦3.5.1或更高

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 are some incompatibility between the version of the binaries you are using.


Solution

Ensure that JDK is upgraded to current levels JDK 8u311.
Incase you are using ChromeDriver / Chrome combo, ensure that:

  • Chrome is upgraded to Chrome Version 100.0.4896.88
  • ChromeDriver is updated to ChromeDriver v100.0 level.

References

You can find a couple of relevant detailed discussions in:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文