Sergei Krivochenko
Sergei Krivochenko

Reputation: 637

'java.lang.LinkageError: loader constraint violation:' error occurred when restarting Springboot project

I have a simple Springboot project

I made settings in my IntelliJ IDE:

  1. Enable compiler.automake.allow.when.app.running checkbox in Registry
  2. Enable Build project automatically in Compiler settings.

Not always but very often when I change my code and save it, I have error:

2018-11-23 05:25:10.544 ERROR 344 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "ru.krivochenko.demo.user.UserService.getNewUser()Lru/krivochenko/demo/user/User;" the class loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @6ce6e730 (instance of org.springframework.boot.devtools.restart.classloader.RestartClassLoader, child of 'app' jdk.internal.loader.ClassLoaders$AppClassLoader) of the current class, ru/krivochenko/demo/MainController, and the class loader 'app' (instance of jdk.internal.loader.ClassLoaders$AppClassLoader) for the method's defining class, ru/krivochenko/demo/user/UserService, have different Class objects for the type ru/krivochenko/demo/user/User used in the signature] with root cause

Full stack trace

Thanks for help!

Upvotes: 1

Views: 2017

Answers (1)

Sergei Krivochenko
Sergei Krivochenko

Reputation: 637

For some reason after rebuild changed class there is a time-gap before it really exists. I played a little bit with values in application.properties I found result working for me:

spring.devtools.restart.poll-interval=3000 spring.devtools.restart.quiet-period=2999

Upvotes: 1

Related Questions