graphql-java / graphql-java-extended-validation

Validation library for graphql-java input
MIT License
128 stars 34 forks source link

Upgrade to spring boot version 2.7.1 fails #71

Closed AnandMandhre closed 2 years ago

AnandMandhre commented 2 years ago

Describe the bug After updating project to spring boot version 2.7.1. Application fails on startup. If I remove directives (@NotNull, @Postive, @connection etc) then application starts up normally

To Reproduce Steps to reproduce the behavior:

Update spring boot to **2.7.1**
Add de dependencies

    <groupId>com.graphql-java-kickstart</groupId>

    <artifactId>graphql-spring-boot-starter</artifactId>

    <version>12.0.0</version>

</dependency>

<dependency>

    <groupId>com.graphql-java-kickstart</groupId>

    <artifactId>graphql-spring-boot-starter-test</artifactId>

     <version>12.0.0</version>

    <scope>test</scope>

</dependency>

<dependency>

     <groupId>com.graphql-java</groupId>

    <artifactId>graphql-java-extended-validation</artifactId>

    <version>18.1-hibernate-validator-6.2.0.Final</version>

</dependency>

See error {"@timestamp":"2022-06-30 19:30:50.234","@Version":"1","message":"Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'graphQLServletRegistrationBean' defined in class path resource [graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQLServletRegistrationBean' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLHttpServlet' defined in class path resource [graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQLHttpServlet' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLServletConfiguration' defined in class path resource [graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQLServletConfiguration' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'invocationInputFactory' defined in class path resource [graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'invocationInputFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in class path resource [graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchema' defined in class path resource [graphql/kickstart/autoconfigure/tools/GraphQLJavaToolsAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'graphQLSchema' threw exception; nested exception is java.lang.NoSuchMethodError: 'graphql.schema.GraphQLDirective graphql.schema.idl.SchemaGeneratorHelper.buildAppliedDirective(graphql.schema.idl.SchemaGeneratorHelper$BuildContext, graphql.language.Directive, java.util.Set, graphql.introspection.Introspection$DirectiveLocation, graphql.schema.GraphqlTypeComparatorRegistry)'","logger":"org.springframework.boot.web.embedded.tomcat.TomcatStarter","thread":"main","level":"ERROR","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.270","@Version":"1","message":"Stopping service [Tomcat]","logger":"org.apache.catalina.core.StandardService","thread":"main","level":"INFO","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.274","@Version":"1","message":"The web application [ROOT] appears to have started a thread named [oracle.jdbc.driver.BlockSource.ThreadedCachingBlockSource.BlockReleaser] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base@15/java.lang.Object.wait(Native Method)\n app//oracle.jdbc.driver.BlockSource$ThreadedCachingBlockSource$BlockReleaser.run(BlockSource.java:331)","logger":"org.apache.catalina.loader.WebappClassLoaderBase","thread":"main","level":"WARN","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.275","@Version":"1","message":"The web application [ROOT] appears to have started a thread named [InterruptTimer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base@15/java.lang.Object.wait(Native Method)\n java.base@15/java.util.TimerThread.mainLoop(Timer.java:553)\n java.base@15/java.util.TimerThread.run(Timer.java:506)","logger":"org.apache.catalina.loader.WebappClassLoaderBase","thread":"main","level":"WARN","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.276","@Version":"1","message":"The web application [ROOT] appears to have started a thread named [AppPool housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base@15/jdk.internal.misc.Unsafe.park(Native Method)\n java.base@15/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)\n java.base@15/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)\n java.base@15/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)\n java.base@15/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)\n java.base@15/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)\n java.base@15/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)\n java.base@15/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)\n java.base@15/java.lang.Thread.run(Thread.java:832)","logger":"org.apache.catalina.loader.WebappClassLoaderBase","thread":"main","level":"WARN","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.277","@Version":"1","message":"The web application [ROOT] appears to have started a thread named [AppPool connection adder] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base@15/jdk.internal.misc.Unsafe.park(Native Method)\n java.base@15/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)\n java.base@15/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)\n java.base@15/java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:460)\n java.base@15/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1055)\n java.base@15/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)\n java.base@15/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)\n java.base@15/java.lang.Thread.run(Thread.java:832)","logger":"org.apache.catalina.loader.WebappClassLoaderBase","thread":"main","level":"WARN","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.278","@Version":"1","message":"The web application [ROOT] appears to have started a thread named [LiquibasePool housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:\n java.base@15/jdk.internal.misc.Unsafe.park(Native Method)\n java.base@15/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)\n java.base@15/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)\n java.base@15/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)\n java.base@15/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)\n java.base@15/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)\n java.base@15/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)\n java.base@15/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)\n java.base@15/java.lang.Thread.run(Thread.java:832)","logger":"org.apache.catalina.loader.WebappClassLoaderBase","thread":"main","level":"WARN","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.279","@Version":"1","message":"Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat","logger":"org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext","thread":"main","level":"WARN","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.282","@Version":"1","message":"AppPool - Shutdown initiated...","logger":"com.zaxxer.hikari.HikariDataSource","thread":"main","level":"INFO","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.433","@Version":"1","message":"AppPool - Shutdown completed.","logger":"com.zaxxer.hikari.HikariDataSource","thread":"main","level":"INFO","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.433","@Version":"1","message":"LiquibasePool - Shutdown initiated...","logger":"com.zaxxer.hikari.HikariDataSource","thread":"main","level":"INFO","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.445","@Version":"1","message":"LiquibasePool - Shutdown completed.","logger":"com.zaxxer.hikari.HikariDataSource","thread":"main","level":"INFO","application":"service-demo"} {"@timestamp":"2022-06-30 19:30:50.498","@Version":"1","message":"\r\nAPPLICATION FAILED TO START Description:An attempt was made to call a method that does not exist. The attempt was made from the following location: graphql.schema.idl.SchemaGeneratorHelperExt.buildAppliedDirective(SchemaGeneratorHelperExt.kt:19). The following method did not exist: 'graphql.schema.GraphQLDirective graphql.schema.idl.SchemaGeneratorHelper.buildAppliedDirective(graphql.schema.idl.SchemaGeneratorHelper$BuildContext, graphql.language.Directive, java.util.Set, graphql.introspection.Introspection$DirectiveLocation, graphql.schema.GraphqlTypeComparatorRegistry)'.The calling method's class, graphql.schema.idl.SchemaGeneratorHelperExt, was loaded from the following location: jar:file:/D:/dev/maven-repo/com/graphql-java-kickstart/graphql-java-tools/11.1.2/graphql-java-tools-11.1.2.jar!/graphql/schema/idl/SchemaGeneratorHelperExt.class. The called method's class, graphql.schema.idl.SchemaGeneratorHelper, is available from the following locations"": jar:file:/D:/dev/maven-repo/com/graphql-java/graphql-java/18.1/ graphql-java-18.1.jar!/graphql/schema/idl/SchemaGeneratorHelper.class\r\n\r\nThe called method's class hierarchy was loaded from the following locations: graphql.schema.idl.SchemaGeneratorHelper: file:/D:/dev/maven-repo/com/graphql-java/graphql-java/18.1/graphql-java-18.1.jar**

Action:Correct the classpath of your application so that it contains compatible versions of the classes graphql.schema.idl.SchemaGeneratorHelperExt and graphql.schema.idl.SchemaGeneratorHelper","logger":"org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter","thread":"main","level":"ERROR","application":"service-demo"}

Expected behavior Normal startup

Desktop (please complete the following information):

OS: [Windows]
Browser [Not Applicable, application fails on startup]
Version [12.0.0]
AnandMandhre commented 2 years ago

OK, I was able to get everything working by adding graphql-java-tools (12.1.0) and explicitly adding the directives that I use in the queries.

default graphql-java-tools version (11.1.2) causes above error (An attempt was made to call a method that does not exist), increasing the version solves the error above but then I get error over directives not found.

Solution: pom: file

com.graphql-java-kickstart graphql-java-tools 12.1.0

`directive @NotBlank(message : String = "graphql.validation.NotBlank.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @Positive(message : String = "graphql.validation.Positive.message") on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @connection(for: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION

getVehicleByColor(color: String! @NotBlank(message : "waarneming.kleur"), first: Int! @Positive(message : "vehicle.first"), after: String @NotBlank(message : "vehicle.after")): VehcileConnection @connection(for: "Vehicle") `