I have a Pom where I have included a dependency for selenium HTML Unit driver. It has a dependency with HtmlUnit v2.18. But While viewing the dependency tree, I was able to see that its picking up another version which I didn't specify, causing issues.
Dependency in my pom:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
Dependency Tree (from terminal):
org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.52.0:compile
[INFO] | +- org.seleniumhq.selenium:selenium-support:jar:2.53.1:compile (version managed from 2.52.0)
[INFO] | | \- org.seleniumhq.selenium:selenium-remote-driver:jar:2.53.1:compile
[INFO] | +- net.sourceforge.htmlunit:htmlunit:jar:2.21:compile (version managed from 2.18)
[INFO] | | +- xalan:xalan:jar:2.7.2:compile
[INFO] | | | \- xalan:serializer:jar:2.7.2:compile
You can clearly see that htmlunit:jar:2.21:compile (version managed from 2.18). I was expecting 2.18.
- I didn't override anything in my pom.xml.
- Also checked the dependency convergence. There was no convergence for htmlunit:jar
How to resolve this issue without adding the appropriate version in our project pom. Note: In spite of this issue, while building and running the project from console it works fine. But for debugging purpose, I need it to run in IDE like Intellij / Eclipse
This is also one of the cause for the issue - htmlunit driver gives me com.gargoylesoftware.htmlunit.html.HtmlPage cannot be cast to com.gargoylesoftware.htmlunit.InteractivePage error
Please add the mave-enforcer-plugin to find out from which dependency your different version will come:
When you know, you could add an exclusion to the dependencies like in this example:
Welcome in the jar hell.