Reputation: 21
One of my Spring Boot applications won't run in my IDE (STS 4.9.0). Maven Build runs without any problem. But if I want to run the app in STS using the Boot Dashboard, I get the following Error:
java.lang.NoSuchMethodError: org.springframework.core.type.AnnotationMetadata.introspect(Ljava/lang/Class;)Lorg/springframework/core/type/AnnotationMetadata;
at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:108)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:276)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at de.berlin.itdz.forms4itdz.kita.app.KitaApp.main(KitaApp.java:27)
05.01.2021 08:35:44 ERROR [main]
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:108)
The following method did not exist:
org.springframework.core.type.AnnotationMetadata.introspect(Ljava/lang/Class;)Lorg/springframework/core/type/AnnotationMetadata;
The method's class, org.springframework.core.type.AnnotationMetadata, is available from the following locations:
jar:file:/Z:/admpetersen/sts-4.9.0.RELEASE/configuration/org.eclipse.osgi/99/0/.cp/lib/spring/spring-core-5.1.4.RELEASE.jar!/org/springframework/core/type/AnnotationMetadata.class
jar:file:/Z:/admpetersen/.m2/repository/org/springframework/spring-core/5.2.10.RELEASE/spring-core-5.2.10.RELEASE.jar!/org/springframework/core/type/AnnotationMetadata.class
The class hierarchy was loaded from the following locations:
org.springframework.core.type.AnnotationMetadata: file:/Z:/admpetersen/sts-4.9.0.RELEASE/configuration/org.eclipse.osgi/99/0/.cp/lib/spring/spring-core-5.1.4.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.core.type.AnnotationMetadata
05.01.2021 08:35:44 DEBUG [main] Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@388ffbc2, started on Tue Jan 05 08:35:44 CET 2021
As the message tells me there are two different versions of the spring core library loaded, a right version as a maven dependency and a wrong version from the included OSGi-Bundle. I really would love to correct the classpath as proposed in the message to exclude the OSGi-Resource. But I don't know how. Neither in the Project Properties (Java Build Path) nor in the Debug Configuration of the Spring Boot App the use of OSGi libraries is mentioned. Obviously they are implicitly included. Does anybody know how to keep them out of the classpath? Thanks in advance!
Some additional notes:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>kita-formular-boot</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.jaspersoft.studio.babel.editor.rbeNature</nature>
</natures>
</projectDescription>
Upvotes: 1
Views: 268
Reputation: 21
Now that I know the reason it sounds easy, but it really took me some time to figure that out. It was a chain of dependencies that led to this strange behavior:
By setting kita-resources as required project all classpaths from kita-resources were also included in kita-formular-boot. So all I had to do was to remove the JasperReports Library Dependencies from the Java Build Path in kita-resources. Obviously they aren't necessary to compile the project. And all conflicts are gone!
Upvotes: 1