spring-projects / spring-graphql

Spring Integration for GraphQL
https://spring.io/projects/spring-graphql
Apache License 2.0
1.53k stars 305 forks source link

Exception with GraphiQlHandler #261

Closed mehhras closed 2 years ago

mehhras commented 2 years ago

Hi All,

I recently faced a problem with GraphiQlHandler, but It used to be OK until yesterday. The problem is that when I want to run my project I see this exception:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.graphql.boot.GraphQlWebMvcAutoConfiguration.graphQlRouterFunction(GraphQlWebMvcAutoConfiguration.java:120)

The following method did not exist:

    'void org.springframework.graphql.web.webmvc.GraphiQlHandler.<init>(java.lang.String)'

The method's class, org.springframework.graphql.web.webmvc.GraphiQlHandler, is available from the following locations:

    jar:file:/C:/Users/mehhr/.gradle/caches/modules-2/files-2.1/org.springframework.graphql/spring-graphql/1.0.0-SNAPSHOT/7c920987c7c8e6c9c00dc95c411dad7d12c69336/spring-graphql-1.0.0-SNAPSHOT.jar!/org/springframework/graphql/web/webmvc/GraphiQlHandler.class

The class hierarchy was loaded from the following locations:

    org.springframework.graphql.web.webmvc.GraphiQlHandler: file:/C:/Users/mehhr/.gradle/caches/modules-2/files-2.1/org.springframework.graphql/spring-graphql/1.0.0-SNAPSHOT/7c920987c7c8e6c9c00dc95c411dad7d12c69336/spring-graphql-1.0.0-SNAPSHOT.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.graphql.web.webmvc.GraphiQlHandler

Thank you in advance.

bclozel commented 2 years ago

Are you still using the experimental starter? This starter is now defunct and you should use the official Spring Boot starter from now on: https://docs.spring.io/spring-boot/docs/2.7.0-SNAPSHOT/reference/html/web.html#web.graphql

mehhras commented 2 years ago

Thank you for your response. I changed it to what this link says.

But my project cannot find RuntimeWiringConfigurer. Is this file in another library?

mehhras commented 2 years ago

And when I commented the line, my builder says:

Could not find org.springframework.boot:spring-boot-starter-graphql:. Should I add another configuration?

bclozel commented 2 years ago

Do you have a sample application we can take a look at? It's probably a build configuration issue.

mehhras commented 2 years ago

Sure. It's my build.gradle

plugins {
    id 'org.springframework.boot' version '2.6.0'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id "com.google.protobuf" version "0.8.15"
    id 'java'
    id 'idea'
}
apply from: 'grpc.gradle'

group = 'XX'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/milestone' }  // Spring milestones
    maven { url 'https://repo.spring.io/snapshot' }   // Spring snapshots
}

task copyDependencies(type: Copy) {
    from configurations.compileClasspath
    into 'build/libs/dependencies'
}

ext {
    set('springCloudVersion', "2020.0.4")
    cxfOutputDir = file("$buildDir/generated/source")
}

idea.module {
    excludeDirs -= file("$buildDir")
    sourceDirs += cxfOutputDir
}

dependencies {
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.6.0'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.6.0'
    implementation group: 'org.springframework.data', name: 'spring-data-commons', version: '2.6.0'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '2.6.0'
    implementation group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '2.6.0'
    implementation group: 'org.springframework', name: 'spring-tx', version: '5.3.12'

    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.6.0'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.6.0'

    implementation group: 'org.springframework.session', name: 'spring-session-core', version: '2.6.0'

    implementation group: 'org.springframework.security', name: 'spring-security-core', version: '5.5.3'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.6.0'

    implementation group: 'org.flywaydb', name: 'flyway-core', version: '8.0.3'

    compileOnly 'org.projectlombok:lombok:1.18.22'
    annotationProcessor 'org.projectlombok:lombok:1.18.22'

    implementation group: 'com.aventrix.jnanoid', name: 'jnanoid', version: '2.0.0'

    implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'

    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'

    implementation 'com.google.code.gson:gson:2.8.9'
    implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.4.3'

    implementation group: 'io.springfox', name: 'springfox-swagger2', version: '3.0.0'
    implementation group: 'org.mapstruct', name: 'mapstruct', version: '1.4.2.Final'

    implementation 'org.apache.commons:commons-lang3:3.12.0'

    implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.23'

    implementation 'io.grpc:grpc-netty-shaded:1.42.0'
    implementation 'io.grpc:grpc-protobuf:1.42.0'
    implementation 'io.grpc:grpc-stub:1.42.0'
    implementation group: 'io.github.lognet', name: 'grpc-spring-boot-starter', version: '4.4.5'

    implementation group: 'io.perfmark', name: 'perfmark-api', version: '0.24.0'
    implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.16.0'
    implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '2.16.0'

    implementation 'org.springframework.boot:spring-boot-starter-graphql'

    testImplementation 'org.springframework.graphql:spring-graphql-test:1.0.0-SNAPSHOT'

    implementation group: 'com.graphql-java', name: 'graphql-java-extended-scalars', version: '17.0'

    testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.4.4'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
    implementation 'org.springframework.boot:spring-boot-starter-actuator:2.5.6'
    implementation 'io.micrometer:micrometer-registry-prometheus:1.8.1'
    implementation 'org.latencyutils:LatencyUtils:2.0.3'
    testImplementation group: 'com.h2database', name: 'h2', version: '2.0.206'

}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }

}

test {
    useJUnitPlatform()
}
bclozel commented 2 years ago

You'll need Spring Boot 2.7.0-SNAPSHOT for that. This is why the starter cannot be found in your project.

spring-projects-issues commented 2 years ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 2 years ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.