GMarsh
GMarsh

Reputation: 23

Failure to parse configuration class

I am trying to build a project that had built and ran previously in a different version of IntelliJ. The error message is as follows :

ERROR o.s.boot.SpringApplication - Application run failed org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [org.wbs.grader.books.BooksApplication]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.wbs.grader.books.BooksApplication at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:325) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:242) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at org.wbs.grader.books.BooksApplication.main(BooksApplication.java:19) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.wbs.grader.books.BooksApplication at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:165) at org.springframework.context.annotation.ConfigurationClassParser.retrieveBeanMethodMetadata(ConfigurationClassParser.java:395) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:320) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:245) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:202) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:170) 17 common frames omitted Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.wbs.grader.books.BooksApplication] from ClassLoader [org.springframework.boot.devtools.restart.classloader.RestartClassLoader@356d44b2] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:477) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:451) at org.springframework.core.type.StandardAnnotationMetadata.getAnnotatedMethods(StandardAnnotationMetadata.java:154) 22 common frames omitted Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext at java.base/java.lang.Class.getDeclaredMethods0(Native Method) at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166) at java.base/java.lang.Class.privateGetPublicMethods(Class.java:3191) at java.base/java.lang.Class.getMethods(Class.java:1904) at org.springframework.util.ReflectionUtils.findConcreteMethodsOnInterfaces(ReflectionUtils.java:487) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:460)

I have tried using different versions of the JDK 8, 11, 17 but all give the same error.

I tried rebuilding the Spring Boot initializer but that had no effect.

Upvotes: 0

Views: 7340

Answers (1)

Udit Mishra
Udit Mishra

Reputation: 108

I think you are not using the subpackage or same package in which your spring application main class is defined so please use this method

You need to move your code into a package of its own. For example, move your .java files into src/main/java/com/example and add package com.example; to the top of each file.

Upvotes: 0

Related Questions