restartedMain Unresolved compilation problem

Spring boot application loads all the beans using bean factory. If any error occurred while invoking the java classes, this exception is thrown



Exception

Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.base/java.lang.reflect.Method.invoke(Unknown Source)
     at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
 Caused by: java.lang.Error: Unresolved compilation problem: 
     SpringApplication cannot be resolved
 at com.yawintutor.SpringBootMySqLApplication.main(SpringBootMySqLApplication.java:11) ... 5 more


Root Cause

Spring boot loads all the java classes using java reflection. The BeanFactory class loads all the beans. If any error occurred while loading a bean in BeanFactory due to reflection, this exception will be thrown.

This error is due to Caused by: java.lang.Error: Unresolved compilation problem It is due to mismatch of java compilation and execution. This error can’t be reproduced.



Solution 1

This issue is due to timing mismatch of java compilation and java execution of a java class. In most of the case, if you restart the application, this issue will be resolved.

If it is not resolved in restart, clean and rebuild the application will resolve this issue.



Solution 2

This issue might occur due to auto configuration. If this issue occurs randomly, then revisit on this dependency.

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>



Related Articles

2 Comments

  • Adiputra , January 6, 2020 @ 12:41 PM

    Dude, how to fix this?
    Exception in thread “restartedMain” java.lang.reflect.InvocationTargetException
    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.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
    at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:79)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:282)
    at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:214)

Leave a Reply

Your email address will not be published. Required fields are marked *