Java.lang.NoClassDefFoundError: com / google / common / collect / Maps - Selenium

Dear Selenium experts,

I encountered the following error while executing a JPA 2.0 program, which for some reason is related to the Firefox profile:

  Exception in thread "main" java.lang.NoClassDefFoundError: com / google / common / collect / Maps
     at org.openqa.selenium.firefox.FirefoxProfile. (FirefoxProfile.java:56)
     at org.openqa.selenium.firefox.FirefoxProfile. (FirefoxProfile.java:79)
     at model.DownloadCarDetail.getMercedezDetail (model.DownloadCarDetail: 72)
     at model.DownloadCarDetail.getMercedezDetail.main (model.DownloadCarDetail.getMercedezDetail.java:47)
     Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
         at java.net.URLClassLoader $ 1.run (URLClassLoader.java data66)
         at java.net.URLClassLoader $ 1.run (URLClassLoader.javahaps55)
         at java.security.AccessController.doPrivileged (Native Method)
         at java.net.URLClassLoader.findClass (URLClassLoader.java data54)
         at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
         at sun.misc.Launcher $ AppClassLoader.loadClass (Launcher.java:308)
         at java.lang.ClassLoader.loadClass (ClassLoader.javahaps57)
     ... 4 more
 Java Result: 1

I saved Firefox to version 15, so it is supported by Selenium Webdriver, but suspects that the problem is due to the inability to read the profile directory.

Your help will be greatly appreciated.

Thank you very much,

George

+7
source share
6 answers

The problem you see has nothing to do with your Firefox profile.

This is actually a JVM class loader that complains that it cannot find the com.google.common.collect.Maps class.

This usually means that you do not have Guava (which depends on Selenium) on your class path. Clean and rebuild your project, check the class path, check the different versions of the libraries that may be there. If you are using some kind of dependency management system (Maven, Ivy, etc.), make sure that it is configured correctly.

+8
source

Thank you for suggesting a solution to this problem. I found the exact answer from Selenium 2 WebDriver NoClassDefFoundErrorS , which solved the main problem.

George

0
source

open this link https://www.seleniumhq.org/download/ and download Java 3.11.0 (current version), open the zip file to your desktop in NetBeans or eclips, click "Add jars / file" in selenium-java-3.11 .0 \ libs select all files also in selenium-java-3.11.0 select client-combined-3.11.0.jar you will be fine. do not forget to add System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe"); code. You can download chromedriver from this link https://chromedriver.storage.googleapis.com/index.html?path=2.38/

0
source

In my case, the dependency on the guava was damaged. It worked fine after I removed the damaged banks and rebuilt the entire project.

0
source

Import the .jar file into Eclipse, downloaded from here (depending on the current version).

0
source

add maven dependency below, clean and compile your code.

 <!-- https://mvnrepository.com/artifact/com.google.common/google-collect --> <dependency> <groupId>com.google.common</groupId> <artifactId>google-collect</artifactId> <version>0.5</version> </dependency> 
0
source

Source: https://habr.com/ru/post/953431/


All Articles