The selenium-java 4 dependency library version is not applied when using Maven with the spring-boot-starter-parent.

706 views
Skip to first unread message

Sunggyu Kam

unread,
Mar 15, 2022, 4:13:16 AM3/15/22
to Selenium Users

I did tried upgrade to the selenium-java 4.1.2 from 3.141.59 by Maven.
However, the dependent library version was not updated.

I suspect a library conflict, so I did some tests.
But I can't find the conflict in case.

I created a new empty project and tested it, it included the spring-boot-starter-parent and the problem occurred.
I have no expert knowledge of Maven.

Explicitly adding dependent library versions solved the problem.
But I'd like to keep the pom.xml as simple as possible.

Is there any workaround for this? can you help me.


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
   
<!-- Problems occurred when this snippet is included.
        <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.6.4</version>
                <relativePath/>
        </parent>
-->

    <groupId>com.example</groupId>
    <artifactId>demo2</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>Selenium Test</name>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
                <dependency>
                        <groupId>org.seleniumhq.selenium</groupId>
                        <artifactId>selenium-java</artifactId>
                        <version>4.1.2</version>
                </dependency>
    </dependencies>
</project>
### Relevant log output ```shell # With spring-boot-starter-parent $ mvn dependency:tree [INFO] --- maven-dependency-plugin:3.2.0:tree (default-cli) @ demo2 --- [INFO] com.example:demo2:jar:1.0-SNAPSHOT [INFO] \- org.seleniumhq.selenium:selenium-java:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-api:jar:3.141.59:compile [INFO] +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.141.59:compile [INFO] | +- net.bytebuddy:byte-buddy:jar:1.11.22:compile [INFO] | +- org.apache.commons:commons-exec:jar:1.3:compile [INFO] | +- com.google.guava:guava:jar:25.0-jre:compile [INFO] | | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile [INFO] | | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile [INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile [INFO] | | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile [INFO] | | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile [INFO] | +- com.squareup.okhttp3:okhttp:jar:3.14.9:compile [INFO] | \- com.squareup.okio:okio:jar:1.14.0:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v85:jar:4.1.2:compile [INFO] | +- com.google.auto.service:auto-service-annotations:jar:1.0.1:compile [INFO] | +- com.google.auto.service:auto-service:jar:1.0.1:compile [INFO] | | \- com.google.auto:auto-common:jar:1.2:compile [INFO] | \- org.seleniumhq.selenium:selenium-json:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v95:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v96:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v97:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.141.59:compile [INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.141.59:compile [INFO] +- org.seleniumhq.selenium:selenium-firefox-xpi-driver:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.141.59:compile [INFO] +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.141.59:compile [INFO] +- org.seleniumhq.selenium:selenium-remote-driver:jar:3.141.59:compile [INFO] +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.141.59:compile [INFO] \- org.seleniumhq.selenium:selenium-support:jar:3.141.59:compile # Without spring-boot-starter-parent $ mvn dependency:tree ... [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ demo2 --- [INFO] com.example:demo2:jar:1.0-SNAPSHOT [INFO] \- org.seleniumhq.selenium:selenium-java:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-api:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-chrome-driver:jar:4.1.2:compile [INFO] | +- com.google.auto.service:auto-service-annotations:jar:1.0.1:compile [INFO] | +- com.google.auto.service:auto-service:jar:1.0.1:compile [INFO] | | \- com.google.auto:auto-common:jar:1.2:compile [INFO] | +- com.google.guava:guava:jar:31.0.1-jre:compile [INFO] | | +- com.google.guava:failureaccess:jar:1.0.1:compile [INFO] | | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile [INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile [INFO] | | +- org.checkerframework:checker-qual:jar:3.12.0:compile [INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.7.1:compile [INFO] | | \- com.google.j2objc:j2objc-annotations:jar:1.3:compile [INFO] | +- org.seleniumhq.selenium:selenium-chromium-driver:jar:4.1.2:compile [INFO] | \- org.seleniumhq.selenium:selenium-json:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v85:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v95:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v96:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-devtools-v97:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-edge-driver:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-firefox-xpi-driver:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-ie-driver:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-opera-driver:jar:4.1.2:compile [INFO] +- org.seleniumhq.selenium:selenium-remote-driver:jar:4.1.2:compile [INFO] | +- com.beust:jcommander:jar:1.82:compile [INFO] | +- io.netty:netty-buffer:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-codec-http:jar:4.1.73.Final:compile [INFO] | | +- io.netty:netty-codec:jar:4.1.73.Final:compile [INFO] | | \- io.netty:netty-handler:jar:4.1.73.Final:compile [INFO] | | \- io.netty:netty-tcnative-classes:jar:2.0.46.Final:compile [INFO] | +- io.netty:netty-common:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-transport-classes-epoll:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-transport-classes-kqueue:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-transport-native-epoll:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-transport-native-kqueue:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-transport-native-unix-common:jar:4.1.73.Final:compile [INFO] | +- io.netty:netty-transport:jar:4.1.73.Final:compile [INFO] | | \- io.netty:netty-resolver:jar:4.1.73.Final:compile [INFO] | +- io.opentelemetry:opentelemetry-api:jar:1.10.1:compile [INFO] | +- io.opentelemetry:opentelemetry-context:jar:1.10.1:compile [INFO] | +- io.opentelemetry:opentelemetry-exporter-logging:jar:1.10.1:compile [INFO] | | +- io.opentelemetry:opentelemetry-sdk-metrics:jar:1.10.1-alpha:compile [INFO] | | \- io.opentelemetry:opentelemetry-sdk-logs:jar:1.10.1-alpha:compile [INFO] | +- io.opentelemetry:opentelemetry-sdk-common:jar:1.10.1:compile [INFO] | +- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:jar:1.10.1:compile [INFO] | +- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:jar:1.10.1-alpha:compile [INFO] | +- io.opentelemetry:opentelemetry-sdk-trace:jar:1.10.1:compile [INFO] | +- io.opentelemetry:opentelemetry-sdk:jar:1.10.1:compile [INFO] | +- io.opentelemetry:opentelemetry-semconv:jar:1.10.1-alpha:compile [INFO] | +- io.ous:jtoml:jar:2.0.0:compile [INFO] | +- net.bytebuddy:byte-buddy:jar:1.12.7:compile [INFO] | +- org.apache.commons:commons-exec:jar:1.3:compile [INFO] | +- org.asynchttpclient:async-http-client:jar:2.12.3:compile [INFO] | | +- org.asynchttpclient:async-http-client-netty-utils:jar:2.12.3:compile [INFO] | | +- io.netty:netty-codec-socks:jar:4.1.60.Final:compile [INFO] | | +- io.netty:netty-handler-proxy:jar:4.1.60.Final:compile [INFO] | | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.60.Final:compile [INFO] | | +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.60.Final:compile [INFO] | | +- org.reactivestreams:reactive-streams:jar:1.0.3:compile [INFO] | | +- com.typesafe.netty:netty-reactive-streams:jar:2.0.4:compile [INFO] | | +- org.slf4j:slf4j-api:jar:1.7.30:compile [INFO] | | \- com.sun.activation:jakarta.activation:jar:1.2.2:compile [INFO] | \- org.seleniumhq.selenium:selenium-http:jar:4.1.2:compile [INFO] | \- net.jodah:failsafe:jar:2.4.4:compile [INFO] +- org.seleniumhq.selenium:selenium-safari-driver:jar:4.1.2:compile [INFO] \- org.seleniumhq.selenium:selenium-support:jar:4.1.2:compile ...
Operating System : Ubuntu 18.04
Selenium version : 4.1.2

⇜Krishnan Mahadevan⇝

unread,
Mar 15, 2022, 5:10:02 AM3/15/22
to Selenium Users
This was an interesting question and while trying to figure out I managed to clear out some of my own misunderstandings too :)

The parent pom file that you are adding merely adds <dependencyManagement> in it. 
This tag can have one or more <dependencies> in it, but those are NEVER applied to your project. You are merely telling Maven that if at all I need a dependency, please check the <dependencyManagement> section to find out what version am I supposed to be resolving to.

But you would still need to add dependencies explicitly into your pom file via the <dependencies> tag.

For an example of this, please check this pom file


Difference between dependencyManagement and dependencies: https://www.baeldung.com/maven-dependencymanagement-vs-dependencies-tags

You can run mvn help:effective-pom

to see what the effective pom file (think of this as an elaborate pom file which is what ultimately maven would use) looks like.


Now coming to the difference in output for mvn dependency:tree for a pom file that involves a parent and no parent, its because 

when you have a spring parent pom file, then some selenium related dependencies (for e.g., io.netty are part of the <dependencyManagement> tag specified. So we are telling Maven that please lock on that version, but don't resolve to it unless and until I explicitly say so).

I am no expert on Maven, but this is what I have managed to infer from what I explored. Hope that helps.

Instead of using a parent pom file, you could maybe consider doing a spring parent import.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ee9bbb54-bd06-4eea-94ed-41b4d381c890n%40googlegroups.com.

Sunggyu Kam

unread,
Mar 15, 2022, 11:33:20 PM3/15/22
to Selenium Users
Hello.  Krishnan Mahadevan

Thank you for your answer.

I tried a few things after writing this issue.
I found something interesting.

I was denied my programming knowledge by this issue. :(
So I decided to give up the dependency resolution and add an explicit version.

Still, I did not want to specify the version directly in all dependent libraries, so I decided to add "selenium.version" as a temporary name to the property.
And I added it all to the dependent library.



pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
   
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/>
    </parent>

    <groupId>com.example</groupId>
    <artifactId>demo2</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>Selenium Test</name>

    <properties>
        <selenium.version>4.1.2</selenium.version>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <!-- This spinet was not required.
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-api</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        ...
        -->
    </dependencies>
</project>

And I compared the dependent:tree result without adding the dependent libraries added to confirm the behavior.
Both results were 4.1.2, and the dependent version was normally applied.
I was denied my knowledge again. :(

As a result of several tests, it worked normally only by adding the "selenium.version" property.
I didn't know why it works like this.

And I saw your answer.
And I looked at the parent node and you can find selenium.version property there. :)
spring-boot-dependencies had selenium.version properties and selenium's dependent libraries were declared.

It was overwritten by defining selenium.version in my pom.
Thanks to you I was able to erase my own misunderstanding too.

And it is not something to suggest here, but it would be better to add version property in selenium-java.
spring is Java's very famous framework and is also considering its dependency on selenium. Selenium is also a very famous framework, so it would be nice to consider the dependency on spring. Selenium can be defined as a selenium-version with the same property name and the dependent libraries version can be added as a property.
it will be very intuitive and beginners like me who try to upgrade to the Selenium4 will be able to relieve their worries.

Anyway, your answer was very helpful to me.
Thank you very much.
2022년 3월 15일 화요일 오후 6시 10분 2초 UTC+9에 Krishnan Mahadevan님이 작성:
Reply all
Reply to author
Forward
0 new messages