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

io.leangen.geantyref.AnnotatedArrayTypeImpl cannot be cast to java.lang.reflect.AnnotatedParameterizedType #442

Open
edsonneri-gbg opened this issue Mar 13, 2023 · 2 comments

Comments

@edsonneri-gbg
Copy link

edsonneri-gbg commented Mar 13, 2023

Hi,
I'm getting this error when trying to start my spring boot server and I'm wondering if it is related to the Kotlin known issue in the doc.

2023-03-13 12:54:47,399  [localhost-startStop-1] ERROR org.springframework.boot.web.embedded.tomcat.TomcatStarter null    - Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'graphQLServlet' defined in com.xx.graphql.config.GraphQLConfiguration: Unsatisfied dependency expressed through method 'graphQLServlet' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQLSchemaProvider' defined in com.xx.graphql.config.GraphQLConfiguration: Unsatisfied dependency expressed through method 'graphQLSchemaProvider' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchema' defined in com.xx.graphql.config.GraphQLConfiguration: 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.ClassCastException: io.leangen.geantyref.AnnotatedArrayTypeImpl cannot be cast to java.lang.reflect.AnnotatedParameterizedType
Caused by: java.lang.ClassCastException: io.leangen.geantyref.AnnotatedArrayTypeImpl cannot be cast to java.lang.reflect.AnnotatedParameterizedType
	at io.leangen.geantyref.GenericTypeReflector.mergeAnnotations(GenericTypeReflector.java:981)
	at java.util.stream.ReduceOps$2ReducingSink.accept(ReduceOps.java:123)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:479)
	at io.leangen.graphql.metadata.TypedElement.<init>(TypedElement.java:28)
	at io.leangen.graphql.metadata.strategy.value.jackson.JacksonValueMapper$ElementFactory.fromProperty(JacksonValueMapper.java:302)
	at io.leangen.graphql.metadata.strategy.value.jackson.JacksonValueMapper.toInputField(JacksonValueMapper.java:132)
	at io.leangen.graphql.metadata.strategy.value.jackson.JacksonValueMapper.lambda$getInputFields$1(JacksonValueMapper.java:126)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at io.leangen.graphql.metadata.strategy.value.jackson.JacksonValueMapper.getInputFields(JacksonValueMapper.java:127)
	at io.leangen.graphql.generator.DelegatingInputFieldBuilder.getInputFields(DelegatingInputFieldBuilder.java:24)
	at io.leangen.graphql.generator.mapping.common.ObjectTypeMapper.toGraphQLInputType(ObjectTypeMapper.java:77)
	at io.leangen.graphql.generator.mapping.common.ObjectTypeMapper.toGraphQLInputType(ObjectTypeMapper.java:32)
	at io.leangen.graphql.generator.mapping.common.CachingMapper.toGraphQLInputType(CachingMapper.java:41)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputType(OperationMapper.java:275)
	at io.leangen.graphql.generator.mapping.common.NonNullMapper.toGraphQLInputType(NonNullMapper.java:75)
	at io.leangen.graphql.generator.mapping.common.NonNullMapper.toGraphQLInputType(NonNullMapper.java:36)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputType(OperationMapper.java:275)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputType(OperationMapper.java:260)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputField(OperationMapper.java:248)
	at io.leangen.graphql.generator.mapping.common.ObjectTypeMapper.lambda$toGraphQLInputType$3(ObjectTypeMapper.java:77)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at io.leangen.graphql.generator.mapping.common.ObjectTypeMapper.toGraphQLInputType(ObjectTypeMapper.java:77)
	at io.leangen.graphql.generator.mapping.common.ObjectTypeMapper.toGraphQLInputType(ObjectTypeMapper.java:32)
	at io.leangen.graphql.generator.mapping.common.CachingMapper.toGraphQLInputType(CachingMapper.java:41)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputType(OperationMapper.java:275)
	at io.leangen.graphql.generator.mapping.common.NonNullMapper.toGraphQLInputType(NonNullMapper.java:75)
	at io.leangen.graphql.generator.mapping.common.NonNullMapper.toGraphQLInputType(NonNullMapper.java:36)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputType(OperationMapper.java:275)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLInputType(OperationMapper.java:260)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLArgument(OperationMapper.java:284)
	at io.leangen.graphql.generator.OperationMapper.lambda$toGraphQLField$6(OperationMapper.java:187)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLField(OperationMapper.java:188)
	at io.leangen.graphql.generator.OperationMapper.toGraphQLField(OperationMapper.java:206)
	at io.leangen.graphql.generator.OperationMapper.generateMutations(OperationMapper.java:149)
	at io.leangen.graphql.generator.OperationMapper.<init>(OperationMapper.java:101)
	at io.leangen.graphql.GraphQLSchemaGenerator.generateExecutable(GraphQLSchemaGenerator.java:1012)
	at io.leangen.graphql.GraphQLSchemaGenerator.generate(GraphQLSchemaGenerator.java:995)
	at com.xx.graphql.config.GraphQLConfiguration.graphQLSchema(GraphQLConfiguration.java:147)
	at com.xx.graphql.config.GraphQLConfiguration$$EnhancerBySpringCGLIB$$a83a5159.CGLIB$graphQLSchema$4(<generated>)
	at com.xx.graphql.config.GraphQLConfiguration$$EnhancerBySpringCGLIB$$a83a5159$$FastClassBySpringCGLIB$$29777edb.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
	at com.xx.graphql.config.GraphQLConfiguration$$EnhancerBySpringCGLIB$$a83a5159.graphQLSchema(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)

My build.gradle:

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.21'
}

apply plugin: 'java'

dependencies {
    compile 'io.leangen.graphql:spqr:0.12.0'
    compile ('com.graphql-java-kickstart:graphql-spring-boot-starter:14.0.0') {
        exclude group: 'org.springframework.boot'
    }
}


compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += ["-Xemit-jvm-type-annotations"]
    }
}
@kaqqao
Copy link
Member

kaqqao commented Mar 14, 2023

Hm, no... At first glance, it seems like the types of some field/getter/setter are not matching. E.g.

private String[] field; //field is an array
...
public List<String> getField() {...} //the related getter returns a list

SPQR tries to deduce the merged type of the property, and it looks like it ran into types of different shapes and thus failed to merge them.

But I don't really know the implications for Kotlin, since getters/setters aren't a thing there... If you don't figure it out, could you by any chance provide a minimal example that reproduces the problem?

@kaqqao
Copy link
Member

kaqqao commented Jun 3, 2023

Any update on this?

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