简体   繁体   中英

NoSuchFieldError EXCLUDE_EMPTY when initiating Eyes Applitools in Gauge

I tried to intiliase Eyes in my automation project, but I am getting this error:

Message: java.lang.NoSuchFieldError: EXCLUDE_EMPTY
Stack Trace:
org.glassfish.jersey.client.ClientConfig$State.<init>(ClientConfig.java:147)
org.glassfish.jersey.client.ClientConfig.<init>(ClientConfig.java:457)
com.applitools.connectivity.api.HttpClientImpl.<init>(HttpClientImpl.java:26)
com.applitools.connectivity.RestClient.<init>(RestClient.java:60)
com.applitools.connectivity.ServerConnector.<init>(ServerConnector.java:42)
com.applitools.connectivity.ServerConnector.<init>(ServerConnector.java:46)
com.applitools.connectivity.ServerConnector.<init>(ServerConnector.java:50)
com.applitools.connectivity.ServerConnector.<init>(ServerConnector.java:54)
com.applitools.eyes.EyesBase.<init>(EyesBase.java:106)
com.applitools.eyes.selenium.Eyes.<init>(Eyes.java:134)

On Eyes eyes = new Eyes();

And my dependencies are:

            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-common</artifactId>
            <version>2.31</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.31</version>
        </dependency>
        <dependency>
            <groupId>com.applitools</groupId>
            <artifactId>eyes-selenium-java4</artifactId>
            <version>4.14.0</version>
        </dependency>

I have tried to switch the jersey versions, restart Intellij, but to no avail. For context, I am using Gauge for automation and Intellij IDEA.

This is Sophie from Applitools. Eyes package already brings Jersey dependencies with it, so you can remove the explicit Jersey dependencies. Also, I would recommend using eyes-selenium-java3 instead of 4.

I ran into a very similar error using jersey-client and jersey-common. My project uses gradle and these are the two interesting dependencies from build.gradle:

    implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version:'2.0.1'
    implementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version:'2.25.1'

This was working for me until I upgraded some other - seemingly unrelated - dependencies. Once I did the upgrade, I started getting the same error as the stacktrace in the question.

After some digging, I discovered that gradle was selecting a dependency I did not want:

$ gradle dependencies
...

+--- org.glassfish.jersey.core:jersey-client:2.25.1
|    +--- javax.ws.rs:javax.ws.rs-api:2.0.1
|    +--- org.glassfish.jersey.core:jersey-common:2.25.1 -> 2.33
|    |    +--- jakarta.ws.rs:jakarta.ws.rs-api:2.1.6

Gradle chose to select version 2.33 for jersey-common instead of the 2.25.1 I wanted. Nowhere in my project to I mention version 2.33. Version 2.33 is also not listed anywhere in the "gradle dependencies" output. Maybe it has something to do with io.spring.dependency-management ?
Notice in the output above that jersey-common version 2.33 uses jakarta.ws.rs:jakarta.ws.rs-api:2.1.6 instead of javax.ws.rs:javax.ws.rs-api:2.0.1

For me the fix was forcing gradle to use the version of jersey-common:

    implementation group: 'org.glassfish.jersey.core', name: 'jersey-common', version:'2.25.1'

After doing that, the dependencies were much more sane:

+--- javax.ws.rs:javax.ws.rs-api:2.0.1
+--- org.glassfish.jersey.core:jersey-client:2.25.1
|    +--- javax.ws.rs:javax.ws.rs-api:2.0.1
|    +--- org.glassfish.jersey.core:jersey-common:2.25.1
|    |    +--- javax.ws.rs:javax.ws.rs-api:2.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM