javaseleniumselenidewebdrivermanager-java

WebDriverManager throwing TypeNotPresentException


I am trying to replace my local geckodriver.exe with WebDriverManager, but when i invoke

WebDriverManager.firefoxdriver().setup();

i get the following error

4391 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Reading https://api.github.com/repos/mozilla/geckodriver/releases to seek geckodriver
4704 [main] WARN io.github.bonigarcia.wdm.WebDriverManager - There was an error managing geckodriver (latest version) (Type com.google.gson.internal.LinkedTreeMap not present) ... trying again using latest driver stored in cache
4704 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Reading https://api.github.com/repos/mozilla/geckodriver/releases to seek geckodriver
4876 [main] ERROR io.github.bonigarcia.wdm.WebDriverManager - There was an error managing geckodriver (latest version) (Type com.google.gson.internal.LinkedTreeMap not present)
java.lang.TypeNotPresentException: Type com.google.gson.internal.LinkedTreeMap not present
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
    ...
    at io.github.bonigarcia.wdm.WebDriverManager.fallback(WebDriverManager.java:825)
    at io.github.bonigarcia.wdm.WebDriverManager.handleException(WebDriverManager.java:802)
    at io.github.bonigarcia.wdm.WebDriverManager.manage(WebDriverManager.java:599)
    at io.github.bonigarcia.wdm.WebDriverManager.setup(WebDriverManager.java:287)

I am using the latest 5.0.3 WebDriverManager from maven

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>5.0.3</version>
</dependency>

Solution

  • TypeNotPresentException is thrown when an application tries to access a type using a string representing the type's name, but no definition for the type with the specified name can be found.

    It's pretty similar to ClassNotFoundException, but not checked during compilation.

    But the root cause is:

    com.google.gson.internal.LinkedTreeMap not present in the project classpath.

    Try to add gson dependency to the project.

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.9.0</version>
    </dependency>