Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 310
George Smith Avatar asked Sep 08 '13 13:09

George Smith


1 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.

like image 141
Petr Janeček Avatar answered Oct 18 '22 05:10

Petr Janeček