Maven Spring Boot Application startup failed - JmxAutoConfiguration.mbeanExporter

Viewed 832

I am using a Spring Boot project for 2 years now and I just tried to get a colleague involved but I could not get the repository to run on his computer. Therefore I have deleted my .m2 folder and cloned the project myself again and I can reproduce the error but the problem is I am not able to fix it.

Spring Boot Version: 1.5.22.RELEASE . Any suggestions?

2021-03-08 15:29:48.563 [restartedMain] INFO  d.a.s.SpringBootproject - No active profile set, falling back to default profiles: default
2021-03-08 15:29:48.709 [background-preinit] INFO  o.h.v.internal.util.Version - HV000001: Hibernate Validator 5.3.6.Final
2021-03-08 15:29:48.789 [restartedMain] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@72d24d6a: startup date [Mon Mar 08 15:29:48 CET 2021]; root of context hierarchy
2021-03-08 15:29:53.456 [restartedMain] INFO  o.s.b.f.x.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
2021-03-08 15:29:53.677 [restartedMain] ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration.mbeanExporter
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:179)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:140)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:272)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:92)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:123)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:666)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:353)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:300)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1082)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1071)
    at de.myproject.project.SpringBootproject.main(SpringBootproject.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.reflect.MalformedParameterizedTypeException: null
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:68)
    at java.lang.reflect.Method.getGenericReturnType(Method.java:255)
    at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:397)
    at org.springframework.core.SerializableTypeWrapper$MethodParameterTypeProvider.getType(SerializableTypeWrapper.java:338)
    at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:146)
    at org.springframework.core.ResolvableType.forType(ResolvableType.java:1346)
    at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1249)
    at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1217)
    at org.springframework.core.ResolvableType.forMethodReturnType(ResolvableType.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:759)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:638)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:607)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1496)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1018)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:217)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:195)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:188)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:175)
    at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:112)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:171)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:158)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:128)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:103)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    ... 22 common frames omitted
2021-03-08 15:29:53.679 [restartedMain] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@72d24d6a: startup date [Mon Mar 08 15:29:48 CET 2021]; root of context hierarchy
2021-03-08 15:29:53.681 [restartedMain] WARN  o.s.boot.SpringApplication - Unable to close ApplicationContext
java.lang.reflect.MalformedParameterizedTypeException: null
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:68)
    at java.lang.reflect.Method.getGenericReturnType(Method.java:255)
    at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:397)
    at org.springframework.core.SerializableTypeWrapper$MethodParameterTypeProvider.getType(SerializableTypeWrapper.java:338)
    at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:146)
    at org.springframework.core.ResolvableType.forType(ResolvableType.java:1346)
    at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1249)
    at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1217)
    at org.springframework.core.ResolvableType.forMethodReturnType(ResolvableType.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:759)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:638)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:607)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1496)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:515)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:508)
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1190)
    at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:785)
    at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:773)
    at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:760)
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:715)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:310)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1082)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1071)
    at de.myproject.project.SpringBootproject.main(SpringBootproject.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

What I have done so far:

  • Fixed all dependencie warnings/errors with maven-resources-plugin
  • Added the following parameter to my application.yml
spring:
    jmx:
       enabled: false
  • Tried to exclude the JmxAutoConfiguration.class in the @SpringBootApplication class
  • Checked that Java 8 is used in Eclipse IDE.

Any help is appreciated.

//EDIT @Deviprasad Sharma

This is the spring boot config:

package de.myproject.project;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;

import de.all4cloud.scan4cloud.config.JpaConfig;
import de.all4cloud.scan4cloud.tenant.settings.SettingsService;

@Import(JpaConfig.class)
@SpringBootApplication(scanBasePackages =
{ "de.myproject.project" }, exclude =
{ DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, FlywayAutoConfiguration.class })
public class SpringBootproject extends SpringBootServletInitializer
{
    @Autowired
    private SettingsService settingsService;

    @Autowired
    private Environment environment;

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
    {
        return application.sources(SpringBootproject.class);
    }

    public static void main(String[] args) throws Exception
    {
        SpringApplication.run(SpringBootproject.class, args);
    }

    @Bean
    public InitializingBean startupDevSettings()
    {
        return () ->
        {
            if (environment.getActiveProfiles().length == 0 || !environment.getActiveProfiles()[0].equals("production"))
            {
                settingsService.devSettings();
            }
        };
    }
}

Line 40 is SpringApplication.run(SpringBootproject.class, args);

2 Answers

Impossible to tell where exact problem is, but

Caused by: java.lang.reflect.MalformedParameterizedTypeException: null
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
    at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)

Is thrown when you have generic declaration with incorrect (or missing) type arguments. More specifically this declaration seems to be on method return type

    at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:68)
    at java.lang.reflect.Method.getGenericReturnType(Method.java:255)

Check for compiler warnings uses unchecked or unsafe operations.

Here is an example of such problem:

public interface Api {
    List<String> methodA();
}

public class Impl implements Api {
    @Override
    List methodA() { return null; }  //here compiler will issue warning
}

Now when Spring try to figure out actual return type arguments of methodA() it will throw exception like in your case.

Run your application in debug mode

You need to pass --debug argument to your program, Spring will be very verbose about what class/bean it is trying to create, which in turn should point to exact problem

Thanks rkosegi.

I have tried different approaches. The --debug option didn't help therefore I started by clearing out all pom dependencies with maven enforcer plugin (mvn enforcer:enforce). Afterwards I was going through all the problems that existed in the project and solved one by one.

Now it is working again.

Related