graphql-java-tools icon indicating copy to clipboard operation
graphql-java-tools copied to clipboard

java.lang.IncompatibleClassChangeError when making Executable Schema

Open Scoppio opened this issue 7 years ago • 1 comments

Spring framework 4.3.4.release graphqa-java-tools 5.2.0 Java 8

Im adding graphQL to a monolith (it is so big that it CANNOT be ported to Spring boot since it excedes the 65k files/classes limit) but there is one error that has stoped all my advances so far.

Everytime I try to instantiate the GraphQLSchema, it crashes saying that it Found interface org.objectweb.asm.MethodVisitor, but class was expected. I have tried changing the creation the GraphQLSchema from a bean to a lazy initializer inside the service, but the error was exactly the same. Ive also tried to replicate the whole package "spring-boot-graphql-autoconfigure" inside my spring framework project (managed to succeed changing a few things about how to register endpoints), but when it tries to initialize the bean for the GraphQLSchema it crashes the same way.

Ive read other issues that have some (or the same) stacktrace, and did tried a few of the solutions, like downgrading to version 4.3.0, tried running mvn clean, then updating it again and rebuilding the project.

Jul 30, 2018 5:08:46 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchema' defined in io.scoppio.graphql.GraphQLJavaToolsAutoConfiguration: 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.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'graphQLSchema' threw exception; nested exception is java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
	... 23 more
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
	at com.esotericsoftware.reflectasm.MethodAccess.get(MethodAccess.java:126)
	at com.coxautodev.graphql.tools.MethodFieldResolverDataFetcher.<init>(MethodFieldResolver.kt:132)
	at com.coxautodev.graphql.tools.MethodFieldResolver.createDataFetcher(MethodFieldResolver.kt:99)
	at com.coxautodev.graphql.tools.SchemaParser$createObject$$inlined$forEach$lambda$1.apply(SchemaParser.kt:126)
	at com.coxautodev.graphql.tools.SchemaParser$createObject$$inlined$forEach$lambda$1.apply(SchemaParser.kt:46)
	at graphql.schema.GraphQLObjectType$Builder.field(GraphQLObjectType.java:173)
	at com.coxautodev.graphql.tools.SchemaParser.createObject(SchemaParser.kt:124)
	at com.coxautodev.graphql.tools.SchemaParser.parseSchemaObjects(SchemaParser.kt:85)
	at com.coxautodev.graphql.tools.SchemaParser.makeExecutableSchema(SchemaParser.kt:109)
	at io.scoppio.graphql.GraphQLJavaToolsAutoConfiguration.graphQLSchema(GraphQLJavaToolsAutoConfiguration.java:59)
	at io.scoppio.graphql.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$ed83f057.CGLIB$graphQLSchema$2(<generated>)
	at io.scoppio.graphql.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$ed83f057$$FastClassBySpringCGLIB$$c4ee8a8a.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
	at io.scoppio.graphql.GraphQLJavaToolsAutoConfiguration$$EnhancerBySpringCGLIB$$ed83f057.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:162)
	... 24 more

Scoppio avatar Jul 30 '18 21:07 Scoppio

Could you upgrade to version 5.2.3 and see if it is fixed? Sounds like issue #152 caused by reflectasm which was fixed in that version.

oliemansm avatar Sep 22 '18 16:09 oliemansm