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

BindableRuntimeHintsRegistrar should handle TypeNotPresentException #43598

Closed
snicoll opened this issue Dec 20, 2024 · 0 comments
Closed

BindableRuntimeHintsRegistrar should handle TypeNotPresentException #43598

snicoll opened this issue Dec 20, 2024 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Dec 20, 2024

If you process an app that has Thymleaf, but not spring-web, it fails as follows:

Exception in thread "main" java.lang.TypeNotPresentException: Type org.springframework.http.MediaType not present
        at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
        at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
        at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at java.base/sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
        at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
        at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at java.base/sun.reflect.generics.repository.ConstructorRepository.computeParameterTypes(ConstructorRepository.java:111)
        at java.base/sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:87)
        at java.base/java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:298)
        at java.base/java.lang.reflect.Method.getGenericParameterTypes(Method.java:334)
        at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:519)
        at org.springframework.core.SerializableTypeWrapper$MethodParameterTypeProvider.getType(SerializableTypeWrapper.java:297)
        at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:106)
        at org.springframework.core.ResolvableType.forType(ResolvableType.java:1530)
        at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1419)
        at org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.getType(JavaBeanBinder.java:371)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.lambda$handleJavaBeanProperties$1(BindableRuntimeHintsRegistrar.java:215)
        at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.handleJavaBeanProperties(BindableRuntimeHintsRegistrar.java:206)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.process(BindableRuntimeHintsRegistrar.java:172)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.processNested(BindableRuntimeHintsRegistrar.java:240)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.handleProperty(BindableRuntimeHintsRegistrar.java:235)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.lambda$handleJavaBeanProperties$1(BindableRuntimeHintsRegistrar.java:215)
        at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.handleJavaBeanProperties(BindableRuntimeHintsRegistrar.java:206)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar$Processor.process(BindableRuntimeHintsRegistrar.java:172)
        at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar.registerHints(BindableRuntimeHintsRegistrar.java:92)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBeanFactoryInitializationAotProcessor$ConfigurationPropertiesReflectionHintsContribution.applyTo(ConfigurationPropertiesBeanFactoryInitializationAotProcessor.java:74)
        at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:96)
        at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
        at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
        at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
        at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
        at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
        at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
        at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80)
Caused by: java.lang.ClassNotFoundException: org.springframework.http.MediaType
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)
        at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
        ... 36 more

If a type cannot be resolved for whatever reason, we should handle that gracefully and continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant