java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap while using WebDriver with Maven Dependencies in Java Selenium

别等时光非礼了梦想. 提交于 2019-12-13 19:08:11

问题


  1. It is portion the code after driver=new ChromeDriver(); line it give me error i check with sysout, errors are in the 2, well i am not well experienced using Maven but i am checking my pom.xml file , i gave Selenium dependencies.

-Any advice?, any helps appreciated

public WebDriver initilizeDriver() throws IOException
{
    Properties prop= new Properties();
    FileInputStream fıs=new FileInputStream("C:\\Users\\Melih Sancak\\my-amazonTest\\src\\main\\java\\com\\ObjectRepisotary\\app\\data.properties");
    prop.load(fıs);
    String browserName =prop.getProperty("browser");
    System.out.println(browserName);
    if(browserName.equals("chrome"))
    {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Melih Sancak\\Downloads\\chromedriver.exe");
        driver=new ChromeDriver();
    }
}

2. Error:

java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
    at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:253)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.<init>(ChromeDriverService.java:94)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)

回答1:


The file com/google/common/collect/ImmutableMap might be corrupted:

Deploying Maven project throws java.util.zip.ZipException: invalid LOC header (bad signature)

If you are using eclipse and want to check whether this file is corrupted just try to open it. It is located in the guava maven dependency. If it is corrupted it will show you invalid LOC header (bad signature).

Then locate the locate the .m2 folder, search for the corrupted file and delete it. Finally run a maven update.

That solved the problem for me.



来源:https://stackoverflow.com/questions/50172479/java-lang-noclassdeffounderror-com-google-common-collect-immutablemap-while-usi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!