Exception in thread restartedmain java lang reflect invocationtargetexception

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

spring boot with spring-boot-starter-data-redis start error #11165

spring boot with spring-boot-starter-data-redis start error #11165

Comments

I import redis with spring-boot-starter-data-redis dependency,when I start my project,the console output

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.NoClassDefFoundError: org/springframework/data/redis/connection/RedisClusterConfiguration at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.getDeclaredMethods(Class.java:1975) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484) 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:1186) at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:818) at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:804) at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:790) at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:744) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.free.framework.Application.main(Application.java:40) . 5 more Caused by: java.lang.ClassNotFoundException: org.springframework.data.redis.connection.RedisClusterConfiguration at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) . 29 more 

The text was updated successfully, but these errors were encountered:

Читайте также:  Java terminate thread pool

Источник

“restartedMain” java.lang.reflect.InvocationTargetException: java.lang.AbstractMethodError

Spring boot application uses inversion of control to load all the dependency classes. Java supports the backward compatibility. If any issue occurred due to compatibility, the exception “java.lang.AbstractMethodError” will be thrown. In this post, the issue of java.lang.AbstractMethodError will be discussed

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)

Root Cause

This problem occurs when some software is updated. If spring boot is upgraded to higher version and mismatch upon class files and jar files compatibility, throws this exception. This issue occurs either at the start of the spring boot or when the dependency class is invoked.

create a spring boot application (say “my application 1.0.0”), dependency jar (api.1.0.0.jar), implemented class jar (impl.1.0.0.jar) in java 1.7.

Now you upgrade the spring boot application (say “my application 1.1.0”), dependency jar (api 1.0.0.jar) and java 1.8.the implemented jar for java 1.8 is (impl.1.1.0.jar).

Now if you assign a class from impl1.1.0.jar to a abstract class in api.1.0.0.jar. Now try to access abstract method that return a dynamically created class from java 1.8 which is not compatible with java 1.7 compiled interface / class then this error occurs..

How to reproduce this issue

create dependency jar (api.1.0.0.jar), implemented class jar (impl.1.0.0.jar) in java 1.7. Upgrade dependency jar (api.1.1.0.jar), implemented class jar (impl.1.1.0.jar) in java 1.8

Create a spring boot project in java 1.7 with dependency jar (api.1.0.0.jar) and implemented class jar (impl.1.1.0.jar)

Solution 1

check all the dependency jars versions and compatibility java version. if any mismatch, tries to upgrade, downgrade, exclude or include the dependency jar version that matches the correct java version

  org.hibernate hibernate-core 5.0.4 

If the issue is due to hibernate loading issue, then tries to downgrade hibernate version say 4.0.0. and try to start spring boot application.

Solution 2

Open your pom.xml in Spring Tool Suite editor, check and compare the dependency jars versions in Dependencies tab and Dependency Hierarchy tab before and after the spring boot application. fix the dependency issue if any change in third party jars version.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Exception in thread «restartedMain» java.lang.reflect.InvocationTargetException #18

Exception in thread «restartedMain» java.lang.reflect.InvocationTargetException #18

Comments

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(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.AbstractMethodError: Receiver class org.springframework.boot.env.EnvironmentPostProcessorApplicationListener does not define or inherit an implementation of the resolved method ‘abstract boolean supportsSourceType(java.lang.Class)’ of interface org.springframework.context.event.SmartApplicationListener.
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)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:185)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:125)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
at info.inet.StudentApplication.main(StudentApplication.java:14)
. 5 more

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

public static void main(String[] args) ApplicationContext ctx = SpringApplication.run(
StudentApplication.class, args);
//System.out.println(ctx);
>
>

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью