Search code examples
javaspringspring-bootwildflyspring-boot-actuator

Restart spring boot application using actuator in wildfly


I am trying to use Spring Boot Actuator to restart the spring to update its newest properties.

I followed this tutorial: https://javapointers.com/spring/spring-boot/how-to-restart-spring-boot-automatically-using-actuator/

So what I did is just to add the properties

management.endpoint.restart.enabled=true
management.endpoints.web.exposure.include=restart,health

and call the endpoint

{host}/actuator/restart

I tested it on my local using the embedded tomcat server, and it works.

But when I tried it in jboss/wildfly, because my client are using it for their production server, it doesn't work.

This is the error that I got:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'server-org.springframework.boot.autoconfigure.web.ServerProperties': Could not bind properties to 'ServerProperties' : prefix=server, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3aa3a991 has been closed already

Please let me know if there is something else that I need to provide.


Solution

  • Maybe You could take a look at Spring Cloud Config to solve properly your problem : Spring Cloud Config

    It allow you to externalize properties, manage them and expose them to clients (like your application).

    And it has some benefits like 'No restart needed'