Java. Lang. Noclassdeffounderror: Com/Google/Common/Collect/Maps - Selenium

Dear Selenium Experts,

I have come across the following run-time error from a JPA 2.0 program which appears to be related to Firefox Profile for some reason:

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:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 4 more
Java Result: 1

I have kept Firefox to version 15 so that it is supported by Selenium Webdriver but suspect that the issue is to do with not able to read profile directory.

Your assistance would be very much apprecaited.

Many thanks,

George

6 Answers

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

Actually, it is the JVM classloader that complains that it can't find the com.google.common.collect.Maps class.

This usually means that you don't have Guava (which is a dependency for Selenium) on your classpath. Clean and rebuild your project, check your classpath, check the various versions of libraries that might be there. If you're using some kind of dependency management system (Maven, Ivy etc.), check it's configured right.

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

1

open this link and download Java 3.11.0(current version) open zip file to desktop on netbeans or eclips click add jars/file in selenium-java-3.11.0\libs select all file also in selenium-java-3.11.0 select client-combined-3.11.0.jar you will be ok. dont remember to add System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe"); code. you can download chromedriver this link

1

In my case the Guava dependency was corrupt. Worked fine after I deleted the corrupt jars and rebuilt whole project.

Thank you for offerring your suggestion for a solution to this issue. I have found the exact answer from Selenium 2 WebDriver NoClassDefFoundErrorS which has resolved the underlying issue.

George

add below maven dependency and clean and compile your code.

<!--  -->
<dependency>
    <groupId>com.google.common</groupId>
    <artifactId>google-collect</artifactId>
    <version>0.5</version>
</dependency>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest