0

When I tried to run my project(no build errors)there was an exception:

 Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.autoconfigure.BackgroundPreinitializer
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:438)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:413)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:270)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:250)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
    at com.inmobi.fuse.FuseServiceAppliaction.main(FuseServiceAppliaction.java:47)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/NativeDetector
    at org.springframework.boot.autoconfigure.BackgroundPreinitializer.<clinit>(BackgroundPreinitializer.java:71)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:208)
    at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:434)
    ... 7 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.NativeDetector
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 14 more

I tried to resolve it, I updated my spring and jdk versions thinking it might be the reason but they all resulted in the same above exception.

  • Does this answer your question? [Why am I getting a NoClassDefFoundError in Java?](https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java) – Alex K Aug 22 '21 at 07:31

1 Answers1

0

Please see https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/. It says

Spring Native 0.10.2 only supports Spring Boot 2.5.3, so change the version if necessary.

If you are running an older version of spring boot than 2.5.3, please try to upgrade and see if that helps.

See https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent for a list of available versions of spring boot.

Kaj Hejer
  • 955
  • 4
  • 18