score:137

Accepted answer

this is unfortunately a know issue with the new spring-boot-devtools module (see https://github.com/spring-projects/spring-boot/issues/3100). we use this trick to kill the main thread so that we can replace it with a re-loadable version. so far i've not found a way to prevent the debug breakpoint from triggering.

for now, you can toggle the "suspend execution on uncaught exceptions" checkbox in java -> debug preferences to prevent it from happening.

score:0

my workaround in kotlin:

@jvmstatic
fun main(args: array<string>) {
  val app = springapplication(application::class.java)
  try {
    app.run(*args)
  } catch (e: exception) {
    preventnonnullexitcodeonsilentexitexception(e)
  }
}

private fun preventnonnullexitcodeonsilentexitexception(e: exception) {
  if (e.tostring().contains("silentexitexception")) {
    log.info("ignoring silent exit exception...")
    e.printstacktrace()
    return
  }
  throw e
}

score:1

try to run devtools at scope runtime:

<dependency>
    <groupid>org.springframework.boot</groupid>
    <artifactid>spring-boot-devtools</artifactid>
    <scope>runtime</scope>
</dependency>

score:1

i had same issue while running spring boot project. i found try catch block used in main method.

remove the try catch block run the code. that error will not come again. like below:

public static void main(string[] args) {

    springapplication.run(trewauthapplication.class, args);

}

score:1

delete these to unknown exceptions & it won't break there: enter image description here

unfortunately, i haven't found a way for this to be permanent, but it should last till the next time you restart eclipse.

score:1

set this in your application.properties file to true.

spring.devtools.restart.enabled=false

also go sure that if you use a spring cloud config server, there is no propertie file that enables this.

score:5

my workaround:

public static void main(string[] args) {
    try {
        springapplication.run(app.class, args);
    } catch (throwable e) {
        if(e.getclass().getname().contains("silentexitexception")) {
            logger.debug("spring is restarting the main thread - see spring-boot-devtools");
        } else {
            logger.error("application crashed!", e);
        }
    }
}

it doesn't matter that we ignore the silentexitexception because the devtools are just restarting the instance with a silentexitexception which isn't very silent. this try block will silence it...

i had to use text matching on the class as the silentexitexception is private in silentexitexceptionhandler.

it doesn't solve your problem with the breakpoint...

score:15

as eclipse on debug mode already allows limited hotpatching, i find the reloader to be counterproductive most of the time and so i decided to disable it by:

system.setproperty("spring.devtools.restart.enabled", "false");

reference: https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable

since that exception is thrown by the reloader, this also solves this issue. note that you'll have to use the system.setproperty method instead of setting it in application.properties.

score:27

add the property as a vm argument:

-dspring.devtools.restart.enabled=false

enter image description here

that way you don't have to change your code, as it is the case when using:

system.setproperty("spring.devtools.restart.enabled", "false");

Related Query

More Query from same tag