Exception java.lang.NoSuchMethodError on ExecutionStrategy constructor method

Viewed 647

I am using GraphQL on a Java project and it was working on a server. When I changed to another server, it stopped working and it is throwing the following exception:

java.lang.NoSuchMethodError: graphql.execution.ExecutionStrategy.(Lgraphql/execution/DataFetcherExceptionHandler;)V at graphql.execution.AbstractAsyncExecutionStrategy.(AbstractAsyncExecutionStrategy.java:19) at graphql.execution.AsyncExecutionStrategy.(AsyncExecutionStrategy.java:23) at graphql.GraphQL$Builder.(GraphQL.java:199) at graphql.GraphQL.newGraphQL(GraphQL.java:166)

I am using exactly the same Java version (1.8.0_181), the same graphql-java dependency version (7.0) and the same project version.

Am I missing something? Anyone with the same problem?

Thanks in advance,

Solution

After analyzing the dependencies of each one of my project dependencies, I noticed graphql-java-annotations was importing version 3.0 of graphql-java library. graphql-java library is one of my project dependencies as mentioned before (was using version 7.0).

As consequence, two different versions of graphql-java where being referenced and were conflicting with each other.

To solve this issue, I removed graphql-java dependency and I started using only the version imported on graphql-java-annotations.

1 Answers

Usually this is because dependency confliction.

You can add this to your pom:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <compilerArgs>
                    <arg>-verbose</arg>
                </compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>

then try package your application, it will log which jar the graphql.execution.ExecutionStrategy class is loaded from. Then you can check if it is the correct version.

Related