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

ClassNotFoundException (RouterFunctions$Visitor) v1.3.8 #646

Closed
agustisanchez opened this issue May 5, 2020 · 6 comments
Closed

ClassNotFoundException (RouterFunctions$Visitor) v1.3.8 #646

agustisanchez opened this issue May 5, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@agustisanchez
Copy link

I got the following error when starting up my Spring Boot application after updating SpringDoc from 1.3.7 to 1.3.8.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springdoc.webmvc.api.OpenApiResource] from ClassLoader [sun.misc.Launcher$AppClassLoader@659e0bfd]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1771) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:847) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
	at com.eccenca.elds.backend.Application.main(Application.java:108) [main/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springdoc.webmvc.api.OpenApiResource] from ClassLoader [sun.misc.Launcher$AppClassLoader@659e0bfd]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:507) ~[spring-core-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:404) ~[spring-core-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.core.MethodIntrospector.selectMethods(MethodIntrospector.java:72) ~[spring-core-5.1.13.RELEASE.jar:5.1.13.RELEASE]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springdoc.webmvc.api.OpenApiResource] from ClassLoader [sun.misc.Launcher$AppClassLoader@659e0bfd]

	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:268) ~[spring-webmvc-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:253) ~[spring-webmvc-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:212) ~[spring-webmvc-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:200) ~[spring-webmvc-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:165) ~[spring-webmvc-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1830) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1767) ~[spring-beans-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/function/RouterFunctions$Visitor
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/function/RouterFunctions$Visitor

	at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_242]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_242]
	at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_242]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.13.RELEASE.jar:5.1.13.RELEASE]
	... 24 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.function.RouterFunctions$Visitor
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_242]
Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.function.RouterFunctions$Visitor

	at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[na:1.8.0_242]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) ~[na:1.8.0_242]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[na:1.8.0_242]
	... 28 common frames omitted
@bnasslahsen
Copy link
Collaborator

@agustisanchez,

Please have a look on the contribution guide before creating many issues:

Are You using spring-boot 1 or spring 4 ?

@agustisanchez
Copy link
Author

springBootVersion = 2.1.12.RELEASE

@bnasslahsen
Copy link
Collaborator

Can you please validate if its fixed with the lastest SNAPSHOT so we can release it asap?

Here is the procedure to use it:

@agustisanchez
Copy link
Author

I tested 1.3.9-SNAPSHOT and I no longer get the reported start-up exception.

I get an NPE when requesting swagger-ui, though.
If it's because the version being SNAPSHOT yet, you can close this issue.

The NPE is thrown when trying to merge schemas.
We have other schema-merge related issues that we plan to report later anyway.

Here's the mentioned NPE on requesting swagger-ui:

Thx

java.lang.NullPointerException: null
        at org.springdoc.core.SpringDocAnnotationsUtils.mergeSchema(SpringDocAnnotationsUtils.java:136) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.core.GenericResponseBuilder.lambda$buildContentFromDoc$2(GenericResponseBuilder.java:173) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[na:1.8.0_191]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) ~[na:1.8.0_191]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_191]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_191]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_191]
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:1.8.0_191]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:1.8.0_191]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_191]
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[na:1.8.0_191]
        at org.springdoc.core.GenericResponseBuilder.buildContentFromDoc(GenericResponseBuilder.java:173) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.core.GenericResponseBuilder.computeResponse(GenericResponseBuilder.java:146) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.core.GenericResponseBuilder.build(GenericResponseBuilder.java:96) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:241) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:334) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.webmvc.api.OpenApiResource.calculatePath(OpenApiResource.java:167) ~[springdoc-openapi-webmvc-core-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.webmvc.api.OpenApiResource.getPaths(OpenApiResource.java:133) ~[springdoc-openapi-webmvc-core-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.api.AbstractOpenApiResource.getOpenApi(AbstractOpenApiResource.java:154) ~[springdoc-openapi-common-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]
        at org.springdoc.webmvc.api.OpenApiResource.openapiJson(OpenApiResource.java:117) ~[springdoc-openapi-webmvc-core-1.3.9-SNAPSHOT.jar:1.3.9-SNAPSHOT]

@alienintheheights
Copy link

alienintheheights commented May 20, 2020

I'm on 1.3.9 (with Spring Boot 2.2.5) and getting the same java.lang.NoClassDefFoundError exception when hitting /api-docs. Same thing as above, it's dying on a static inner class.

java.lang.Class.getDeclaringClass0(Native Method)\n\tat java.lang.Class.getDeclaringClass(Class.java:1235)\n\tat java.lang.Class.getEnclosingClass(Class.java:1277)\n\tat java.lang.Class.getSimpleBinaryName(Class.java:1443)\n\tat java.lang.Class.getSimpleName(Class.java:1309)\n\tat io.swagger.v3.core.jackson.TypeNameResolver.nameForClass(TypeNameResolver.java:51)\n\tat io.swagger.v3.core.jackson.TypeNameResolver.nameForClass(TypeNameResolver.java:40)\n\tat io.swagger.v3.core.jackson.TypeNameResolver.nameForType(TypeNameResolver.java:36)\n\tat io.swagger.v3.core.jackson.TypeNameResolver.nameForType(TypeNameResolver.java:27)\n\tat io.swagger.v3.core.jackson.AbstractModelConverter._findTypeName(AbstractModelConverter.java:96)\n\tat io.swagger.v3.core.jackson.AbstractModelConverter._typeName(AbstractModelConverter.java:67)\n\tat io.swagger.v3.core.jackson.ModelResolver.resolve(ModelResolver.java:175)\n\tat org.springdoc.core.converters.AdditionalModelsConverter.resolve(AdditionalModelsConverter.java:67)\n\tat org.springdoc.core.converters.PropertyCustomizingConverter.resolve(PropertyCustomizingConverter.java:44)\n\tat org.springdoc.core.converters.FileSupportConverter.resolve(FileSupportConverter.java:46)\n\tat org.springdoc.core.converters.ResponseSupportConverter.resolve(ResponseSupportConverter.java:58)\n\tat org.springdoc.core.converters.SchemaPropertyDeprecatingConverter.resolve(SchemaPropertyDeprecatingConverter.java:48)\n\tat io.swagger.v3.core.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:90)\n\tat io.swagger.v3.core.converter.ModelConverters.resolveAsResolvedSchema(ModelConverters.java:112)\n\tat org.springdoc.core.SpringDocAnnotationsUtils.extractSchema(SpringDocAnnotationsUtils.java:71)\n\tat org.springdoc.core.SpringDocAnnotationsUtils.extractSchema(SpringDocAnnotationsUtils.java:99)\n\tat org.springdoc.core.GenericResponseBuilder.calculateSchema(GenericResponseBuilder.java:268)\n\tat org.springdoc.core.GenericResponseBuilder.buildContent(GenericResponseBuilder.java:243)\n\tat org.springdoc.core.GenericResponseBuilder.buildApiResponses(GenericResponseBuilder.java:281)\n\tat org.springdoc.core.GenericResponseBuilder.buildApiResponses(GenericResponseBuilder.java:206)\n\tat org.springdoc.core.GenericResponseBuilder.computeResponse(GenericResponseBuilder.java:155)\n\tat org.springdoc.core.GenericResponseBuilder.build(GenericResponseBuilder.java:96)\n\tat org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:241)\n\tat org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:334)\n\tat org.springdoc.webmvc.api.OpenApiResource.calculatePath(OpenApiResource.java:167)\n\tat org.springdoc.webmvc.api.OpenApiResource.getPaths(OpenApiResource.java:133)\n\tat org.springdoc.api.AbstractOpenApiResource.getOpenApi(AbstractOpenApiResource.java:154)\n\tat org.springdoc.webmvc.api.OpenApiResource.openapiJson(OpenApiResource.java:117)\n\tat

@bnasslahsen
Copy link
Collaborator

@alienintheheights,

If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible:

  • You need to describe your context (the title of an issue is not enough)
  • What version of spring-boot you are using?
  • What modules and versions of springdoc-openapi are you using?
  • What are the actual and the expected result using OpenAPI Description (yml or json)?
  • Provide with a sample code (HelloController) or Test that reproduces the problem

@bnasslahsen bnasslahsen added the bug Something isn't working label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants