Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Could not initialize class net.serenitybdd.rest.utils.RestSpecificationFactory #2771

Open
ju1ianj0rdan opened this issue Apr 8, 2022 · 4 comments

Comments

@ju1ianj0rdan
Copy link

ju1ianj0rdan commented Apr 8, 2022

I have an issue where I keep running into this above "Could not initialize class net.serenitybdd.rest.utils.RestSpecificationFactory" issue. I am running a Serenity, Appium Cucumber project with Serenity 3.2.3, Appium v2, and Cucumber 7(as well as SpringBoot 5.2.3) on JDK 17.

I've noticed, that when I switch my JDK to version 11, I get this error instead of the above.

java.util.Set io.restassured.config.LogConfig.blacklistedHeaders()

The error is specifically occurring when trying to make a call using the SharedLibrary of the integration tests that are imported from another project.

Would anyone be able to help me troubleshoot the issue here?


4.0.0

<groupId>testing</groupId>
<artifactId>appium-tests</artifactId>

<version>1.0-SNAPSHOT</version>
<parent>
    <groupId>parent</groupId>
    <artifactId>integration-parent-pom</artifactId>
    <version>2.2.0-SNAPSHOT</version>
    <relativePath/>
</parent>

<properties>
    <selenium.version>4.1.2</selenium.version>
    <serenity.version>3.2.3</serenity.version>
    <cucumber.version>7.2.3</cucumber.version>
    <maven.surefire.plugin.version>3.0.0-M6</maven.surefire.plugin.version>
    <maven.failsafe.plugin.version>3.0.0-M6</maven.failsafe.plugin.version>
    <maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
</properties>

<build>
    <plugins>
        <!-- Surefire (Unit) & Failsafe Integration Test Configuration cof MVN execution command -->
        <!-- See https://maven.apache.org/surefire/maven-failsafe-plugin/usage.html for more on failsafe-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.plugin.version}</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven.failsafe.plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- Surefire (Unit) & Failsafe Integration Test Configuration on MVN execution command -->

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.version}</version>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- Serenity Core & Maven Plugin Configuration -->

    </plugins>
</build>

<dependencies>

    <!--Integration test suites-->
    <dependency>
        <groupId>testing</groupId>
        <artifactId>core-api-integration</artifactId>
        <version>2.2.0-SNAPSHOT</version>
    </dependency>

    <!--Sauce Labs Dependencies-->
    <dependency>
        <groupId>com.saucelabs</groupId>
        <artifactId>saucerest</artifactId>
        <version>1.1.0</version>
    </dependency>
    <!--Sauce Labs Dependencies-->

    <!--Serenity Dependencies Through Which The Latest Version of Cucumber is also automatically imported-->
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay-webdriver</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-ensure</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <!--Serenity Dependencies Through Which The Latest Version of Cucumber is also automatically imported-->


    <!-- JUnit Dependencies -->
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>5.8.2</version>
    </dependency>
    <!-- JUnit Dependencies -->

    <!-- Assert J Logging Dependencies -->
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.22.0</version>
    </dependency>
    <!-- Assert J Logging Dependencies -->

    <!-- Unknown Slightly Random Google Dependencies Required to Avoid Build Error-->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>31.1-jre</version>
    </dependency>
    <!-- Unknown Slightly Random Google Dependencies Required to Avoid Build Error-->


    <!--Likely uneeded Serenity Plugins downloaded to try to get backend calls working -->
    <dependency>
        <groupId>org.glassfish.jersey.inject</groupId>
        <artifactId>jersey-hk2</artifactId>
        <version>3.0.4</version>
    </dependency>



    <!--Likely uneeded Serenity Plugins downloaded to try to get backend calls working -->

    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-engine</artifactId>
        <version>1.8.2</version>
    </dependency>

    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-commons</artifactId>
        <version>1.8.2</version>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.8.2</version>
    </dependency>

</dependencies>
@ricardorlg-yml
Copy link

be sure that u don't have a different serenity version in any project, also a different rest assured, do a dependencies analysis.

@ju1ianj0rdan
Copy link
Author

Ahh that is helpful to know, so will a dependency discrepancy cause the tests to fail? For instance, if this repo is running serenity v3.2.3, but is depending on integration tests of a repo that is on serenity v.2.0.70?

My initial thought was that as long as the other repo was working in isolation, it wouldn't cause any issues, but is that not correct?

@ricardorlg-yml
Copy link

the problem is that if in project A u have a dependency of serenity that transitively depends for example on rest-assured 4, but in the project B u have another serenity version that has rest-assured 3, then u will have conflicting versions, so in that case, u will have to add project b as dependency and exclude the transitive dependencies so at resolution only the ones of project A are used.

but as mention try to check first, on your dependencies which rest-assured version is present.

@ju1ianj0rdan
Copy link
Author

Ahh okay that makes a ton of sense! I can try this to see if it may resolve the issue, here are the rest-assured dependencies for both of my projects. It seems that tehy are using 3.3 for rest assured? And also, project A doens't directly use rest Assured (it only uses Appium) all of the API calls are made using dependencies from Project B.

Project A:

+- net.serenity-bdd:serenity-rest-assured:jar:3.2.3:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
[INFO] | | - org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] | +- io.rest-assured:rest-assured:jar:3.3.0:compile
[INFO] | | +- org.hamcrest:hamcrest-core:jar:2.1:compile
[INFO] | | +- org.hamcrest:hamcrest-library:jar:2.1:compile
[INFO] | | +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] | | +- io.rest-assured:json-path:jar:3.3.0:compile
[INFO] | | | - io.rest-assured:rest-assured-common:jar:3.3.0:compile
[INFO] | | - io.rest-assured:xml-path:jar:3.3.0:compile

Project B:

[INFO] +- net.serenity-bdd:serenity-rest-assured:jar:2.0.70:compile
[INFO] | +- io.rest-assured:rest-assured:jar:3.3.0:compile
[INFO] | | +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] | | +- io.rest-assured:json-path:jar:3.3.0:compile
[INFO] | | | - io.rest-assured:rest-assured-common:jar:3.3.0:compile
[INFO] | | - io.rest-assured:xml-path:jar:3.3.0:compile
[INFO] | | +- com.sun.xml.bind:jaxb-osgi:jar:2.2.10:compile
[INFO] | | - org.apache.sling:org.apache.sling.javax.activation:jar:0.1.0:compile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants