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

Observability module strongly depends on micrometer-tracing #501

Closed
igbanam opened this issue Feb 13, 2024 · 3 comments
Closed

Observability module strongly depends on micrometer-tracing #501

igbanam opened this issue Feb 13, 2024 · 3 comments
Assignees
Labels
in: observability Observability support type: bug Something isn't working
Milestone

Comments

@igbanam
Copy link

igbanam commented Feb 13, 2024

Hello maintainers,

Looks like there's an implicit requirement to always have Spring Observability setup when working with Spring Modulith. Should this be? Can this be relaxed?

I bumped into this when I added the Spring Modulith dependency, and added the Actuator Starter dependency, but did not add the dependencies required for observability yet. You can use this initializer to reproduce.

Steps?

  • Download the initialized project
  • run mvn spring-boot:run

Expectation

I expected this should just work™ i.e. start a Spring app waiting for connections.

The error I got was some inability to introspect into some micrometer class.

java.lang.IllegalStateException: Error processing condition on org.springframework.modulith.runtime.autoconfigure.SpringModulithRuntimeAutoConfiguration.modulithsApplicationRuntime
        at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:183) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:428) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:289) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:606) ~[spring-context-6.1.3.jar:6.1.3]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.2.jar:3.2.2]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-3.2.2.jar:3.2.2]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456) ~[spring-boot-3.2.2.jar:3.2.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:334) ~[spring-boot-3.2.2.jar:3.2.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.2.jar:3.2.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.2.jar:3.2.2]
        at com.therubycentre.core.CoreApplication.main(CoreApplication.java:10) ~[classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.modulith.observability.autoconfigure.ModuleObservabilityAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@531d72ca]
        at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-6.1.3.jar:6.1.3]
        at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:360) ~[spring-core-6.1.3.jar:6.1.3]
        at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:417) ~[spring-core-6.1.3.jar:6.1.3]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$1(AbstractAutowireCapableBeanFactory.java:749) ~[spring-beans-6.1.3.jar:6.1.3]
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1740) ~[na:na]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:748) ~[spring-beans-6.1.3.jar:6.1.3]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681) ~[spring-beans-6.1.3.jar:6.1.3]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:652) ~[spring-beans-6.1.3.jar:6.1.3]
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1644) ~[spring-beans-6.1.3.jar:6.1.3]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:562) ~[spring-beans-6.1.3.jar:6.1.3]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:534) ~[spring-beans-6.1.3.jar:6.1.3]
        at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:247) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:240) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:230) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:183) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:158) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-3.2.2.jar:3.2.2]
        ... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: io/micrometer/tracing/Tracer
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[na:na]
        at java.base/java.lang.Class.getDeclaredMethods(Class.java:2504) ~[na:na]
        at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:465) ~[spring-core-6.1.3.jar:6.1.3]
        ... 33 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.micrometer.tracing.Tracer
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
        ... 37 common frames omitted
@igbanam
Copy link
Author

igbanam commented Feb 13, 2024

If someone runs into this issue as well, adding the dependencies for Spring Observability from this article fixes it.

@odrotbohm
Copy link
Member

There's no “using Spring Modulith” and no “the Spring Modulith dependency”. What's needed or not depends on which of the starters / Spring Modulith modules you use. Those are documented here.

As you have discovered (and this probably needs to be documented better or fixed) is that the observability module requires micrometer-tracing on the classpath.

@odrotbohm odrotbohm changed the title Should a new app break because no Observability? Observability module strongly depends on micrometer-tracing Feb 14, 2024
@odrotbohm odrotbohm self-assigned this Feb 14, 2024
@odrotbohm odrotbohm added in: observability Observability support type: bug Something isn't working labels Feb 14, 2024
@odrotbohm odrotbohm added this to the 1.2 M2 milestone Feb 14, 2024
odrotbohm added a commit that referenced this issue Feb 19, 2024
…ability module.

ModuleObservabilityAutoConfiguration strongly depends on said module and there's no way to make it optionally depending on that.
@odrotbohm
Copy link
Member

This should be fixed now. If you fancy giving the snapshots a try, altering the BOM version declared from a freshly created project to 1.2.0-SNAPSHOT should make the project start properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: observability Observability support type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants