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

GraphQL FAIL_ON_EMPTY_BEANS #120

Open
2 of 4 tasks
oo00spy00oo opened this issue Oct 1, 2020 · 1 comment
Open
2 of 4 tasks

GraphQL FAIL_ON_EMPTY_BEANS #120

oo00spy00oo opened this issue Oct 1, 2020 · 1 comment

Comments

@oo00spy00oo
Copy link

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Expected Behaviour

Is this issue related to configuration?

Actual Behaviour

14:06:15.726 [pool-2-thread-2] ERROR i.m.s.DefaultTaskExceptionHandler - Error invoking scheduled task Error instantiating bean of type [io.micronaut.configuration.graphql.ws.GraphQLWsKeepAlive]: Error serializing object to JSON: No serializer found for class io.micronaut.configuration.graphql.ws.GraphQLWsResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [io.micronaut.configuration.graphql.ws.GraphQLWsKeepAlive]: Error serializing object to JSON: No serializer found for class io.micronaut.configuration.graphql.ws.GraphQLWsResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1918)
	at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2638)
	at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2624)
	at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2296)
	at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2270)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:716)
	at io.micronaut.scheduling.processor.ScheduledMethodProcessor.lambda$process$5(ScheduledMethodProcessor.java:123)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(Thread.java:834)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:517)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.RuntimeException: Error serializing object to JSON: No serializer found for class io.micronaut.configuration.graphql.ws.GraphQLWsResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
	at io.micronaut.configuration.graphql.JacksonGraphQLJsonSerializer.serialize(JacksonGraphQLJsonSerializer.java:51)
	at io.micronaut.configuration.graphql.ws.GraphQLWsKeepAlive.<init>(GraphQLWsKeepAlive.java:55)
	at io.micronaut.configuration.graphql.ws.$GraphQLWsKeepAliveDefinition.build(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1889)
	... 14 common frames omitted
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class io.micronaut.configuration.graphql.ws.GraphQLWsResponse and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1277)
	at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:71)
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:33)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4407)
	at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3661)
	at io.micronaut.configuration.graphql.JacksonGraphQLJsonSerializer.serialize(JacksonGraphQLJsonSerializer.java:49)
	... 17 common frames omitted

Environment Information

  • Operating System: MacOSX 10.15
  • Micronaut Version: 2.0.3
  • JDK Version: 11

build.gradle

plugins {
    id "com.diffplug.eclipse.apt" version "3.22.0"
    id "groovy"
    id "com.github.johnrengelman.shadow" version "6.0.0"
    id "application"
    id "org.sonarqube" version "3.0"
}

version "0.1"
group "io.example"

repositories {
    mavenCentral()
    jcenter()
}

configurations {
    // for dependencies that are needed for development only
    developmentOnly
}

dependencies {
    compileOnly("org.projectlombok:lombok:$lombokVersion")
    annotationProcessor("org.projectlombok:lombok:$lombokVersion")
    annotationProcessor(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    annotationProcessor("io.micronaut:micronaut-inject-java")
    annotationProcessor("io.micronaut:micronaut-validation")
    annotationProcessor("io.micronaut:micronaut-graal")
    compileOnly(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    compileOnly("org.graalvm.nativeimage:svm")
    implementation(platform("io.micronaut:micronaut-bom:$micronautVersion"))
    implementation("io.micronaut:micronaut-inject")
    implementation("io.micronaut:micronaut-validation")
    implementation("io.micronaut:micronaut-runtime")
    implementation("javax.annotation:javax.annotation-api")
    implementation("io.micronaut:micronaut-http-server-netty")
    implementation("io.micronaut:micronaut-http-client")
    implementation("io.micronaut.flyway:micronaut-flyway")
    implementation("io.micronaut.sql:micronaut-jdbc-hikari")
    implementation("io.micronaut.beanvalidation:micronaut-hibernate-validator")
    implementation("io.micronaut.sql:micronaut-hibernate-jpa")
    implementation("io.micronaut.graphql:micronaut-graphql")
    implementation("io.micronaut.cache:micronaut-cache-caffeine")
    runtimeOnly("ch.qos.logback:logback-classic")
    runtimeOnly("org.postgresql:postgresql")
    implementation("com.graphql-java-kickstart:graphql-java-tools:$graphqlJavaToolsVersion")

    testCompileOnly("org.projectlombok:lombok:$lombokVersion")
    testAnnotationProcessor("org.projectlombok:lombok:$lombokVersion")
    testImplementation(enforcedPlatform("io.micronaut:micronaut-bom:$micronautVersion"))
    testImplementation("io.micronaut:micronaut-inject-groovy")
    testImplementation("org.spockframework:spock-core") {
        exclude group: "org.codehaus.groovy", module: "groovy-all"
    }
    testImplementation("io.micronaut.test:micronaut-test-spock")

    testImplementation(platform("org.testcontainers:testcontainers-bom:1.14.3"))
    testRuntimeOnly("org.testcontainers:postgresql")

    implementation('com.github.javafaker:javafaker:1.0.2')
}

test.classpath += configurations.developmentOnly

mainClassName = "io.passiontech.Application"

// use JUnit 5 platform
test {
    useJUnitPlatform()
}

java {
    sourceCompatibility = JavaVersion.toVersion('11')
    targetCompatibility = JavaVersion.toVersion('11')
}

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
    options.compilerArgs.addAll([
        '-parameters',
        // enables incremental compilation
        '-Amicronaut.processing.incremental=true',
        '-Amicronaut.processing.annotations=io.passiontech.*',
        "-Amicronaut.processing.group=$project.group",
        "-Amicronaut.processing.module=$project.name",
    ])
}

shadowJar {
    mergeServiceFiles()
}

tasks.withType(JavaExec) {
    classpath += configurations.developmentOnly
    jvmArgs('-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
    if (gradle.startParameter.continuous) {
        systemProperties(
            'micronaut.io.watch.restart':'true',
            'micronaut.io.watch.enabled':'true',
            "micronaut.io.watch.paths":"src/main"
        )
    }
}
@oo00spy00oo oo00spy00oo changed the title GraphQL GraphQL FAIL_ON_EMPTY_BEANS Oct 1, 2020
@graemerocher graemerocher transferred this issue from micronaut-projects/micronaut-core Oct 1, 2020
@sanimalp
Copy link

sanimalp commented Jul 3, 2023

Tossing my hat in the ring that I had this error also.

Explicitly disabling GWL over WS does appear to avoid the issue, however.

graphql:
  graphql-ws:
    enabled: false

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