2018-11-27 12:09:58.463 INFO 20344 --- [ Thread-113] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@23d23d98: startup date [Tue Nov 27 12:07:41 IST 2018]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5a62b2a4 2018-11-27 12:09:58.466 INFO 20344 --- [ Thread-113] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5a62b2a4: startup date [Tue Nov 27 12:07:23 IST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@53fe15ff 2018-11-27 12:09:58.467 INFO 20344 --- [ Thread-113] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application xc-auth-server with eureka with status DOWN 2018-11-27 12:09:58.467 WARN 20344 --- [ Thread-113] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1543300798467, current=DOWN, previous=UP] 2018-11-27 12:09:58.467 INFO 20344 --- [ Thread-113] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@753e4eb5: startup date [Tue Nov 27 12:07:48 IST 2018]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5a62b2a4 2018-11-27 12:09:58.468 INFO 20344 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_XC-AUTH-SERVER/xc-auth-server: registering service... 2018-11-27 12:09:58.472 INFO 20344 --- [ Thread-113] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147483647 2018-11-27 12:09:58.473 INFO 20344 --- [ Thread-113] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147483547 2018-11-27 12:09:58.473 INFO 20344 --- [ Thread-113] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147482647 2018-11-27 12:09:58.476 INFO 20344 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_XC-AUTH-SERVER/xc-auth-server - registration status: 204 2018-11-27 12:09:58.484 INFO 20344 --- [container-0-C-1] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 2018-11-27 12:09:58.923 INFO 20344 --- [container-0-C-1] essageListenerContainer$ListenerConsumer : Consumer stopped 2018-11-27 12:09:58.924 INFO 20344 --- [ Thread-113] s.i.k.i.KafkaMessageDrivenChannelAdapter : stopped org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter@9ba167e 2018-11-27 12:09:58.924 INFO 20344 --- [ Thread-113] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0 2018-11-27 12:09:58.924 INFO 20344 --- [ Thread-113] o.s.i.endpoint.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel 2018-11-27 12:09:58.924 INFO 20344 --- [ Thread-113] o.s.i.channel.PublishSubscribeChannel : Channel 'xc-auth-server-1.errorChannel' has 0 subscriber(s). 2018-11-27 12:09:58.924 INFO 20344 --- [ Thread-113] o.s.i.endpoint.EventDrivenConsumer : stopped _org.springframework.integration.errorLogger 2018-11-27 12:09:58.924 INFO 20344 --- [ Thread-113] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase -2147482648 2018-11-27 12:09:58.926 INFO 20344 --- [ Thread-113] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown 2018-11-27 12:09:58.927 INFO 20344 --- [ Thread-113] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans 2018-11-27 12:09:58.931 INFO 20344 --- [ Thread-113] s.c.a.AnnotationConfigApplicationContext : Closing FeignContext-xc-application-registry: startup date [Tue Nov 27 12:07:32 IST 2018]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5a62b2a4 2018-11-27 12:09:58.933 INFO 20344 --- [ Thread-113] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler' 2018-11-27 12:09:58.934 INFO 20344 --- [ Thread-113] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ... 2018-11-27 12:10:01.937 INFO 20344 --- [ Thread-113] com.netflix.discovery.DiscoveryClient : Unregistering ... 2018-11-27 12:10:01.951 INFO 20344 --- [ Thread-113] com.netflix.discovery.DiscoveryClient : DiscoveryClient_XC-AUTH-SERVER/xc-auth-server - deregister status: 200 2018-11-27 12:10:01.963 INFO 20344 --- [ Thread-113] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient 2018-11-27 12:10:01.963 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Unregistering JMX-exposed beans on shutdown 2018-11-27 12:10:01.963 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Unregistering JMX-exposed beans 2018-11-27 12:10:01.964 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: apikeys-channel-readable 2018-11-27 12:10:01.964 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: errorChannel 2018-11-27 12:10:01.964 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: apikeys-channel-writable 2018-11-27 12:10:01.964 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: nullChannel 2018-11-27 12:10:01.964 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: org.springframework.cloud.stream.binding.StreamListenerMessageHandler@320e179f 2018-11-27 12:10:01.964 INFO 20344 --- [ Thread-113] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: _org.springframework.integration.errorLogger.handler 2018-11-27 12:10:02.563 INFO 20344 --- [ Thread-113] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2018-11-27 12:10:02.568 INFO 20344 --- [ost-startStop-2] o.apache.catalina.core.StandardWrapper : Waiting for [1] instance(s) to be deallocated for Servlet [dispatcherServlet] 2018-11-27 12:10:03.573 INFO 20344 --- [ost-startStop-2] o.apache.catalina.core.StandardWrapper : Waiting for [1] instance(s) to be deallocated for Servlet [dispatcherServlet] 2018-11-27 12:10:04.577 INFO 20344 --- [ost-startStop-2] o.apache.catalina.core.StandardWrapper : Waiting for [1] instance(s) to be deallocated for Servlet [dispatcherServlet] 2018-11-27 12:10:04.677 INFO 20344 --- [ost-startStop-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Destroying Spring FrameworkServlet 'dispatcherServlet' 2018-11-27 12:10:04.699 INFO 20344 --- [ Thread-113] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@53fe15ff: startup date [Tue Nov 27 12:07:15 IST 2018]; root of context hierarchy 2018-11-27 12:10:04.702 INFO 20344 --- [ Thread-113] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 2018-11-27 12:10:04.706 ERROR 20344 --- [ Thread-113] o.s.boot.SpringApplication : Application run failed

java.lang.IllegalStateException: org.springframework.context.annotation.AnnotationConfigApplicationContext@53fe15ff has been closed already at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1073) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1185) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.getOrderedBeansOfType(BootstrapApplicationListener.java:329) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.apply(BootstrapApplicationListener.java:303) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:107) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:70) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE] at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:364) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE] at org.springframework.cloud.context.restart.RestartEndpoint.doRestart(RestartEndpoint.java:160) [spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.cloud.context.restart.RestartEndpoint.safeRestart(RestartEndpoint.java:99) [spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_181] 2018-11-27 12:10:04.706 INFO 20344 --- [ Thread-113] o.s.c.context.restart.RestartEndpoint : Could not doRestart: org.springframework.context.annotation.AnnotationConfigApplicationContext@53fe15ff has been closed already

Process finished with exit code 0

Comment From: ryanjbaxter

Please learn how to format code on GitHub.

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Comment From: spencergibb

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: vinson-bs

Hello, I found out after the introduction of [ spring-cloud-starter-bus-amqp]; This error will be reported when you restart the server with /actuator/restart.

But using [@SpringBootApplication (exclude = {BusAutoConfiguration.Class})] excluded BusAutoConfiguration.Class; This error will not be reported.

Spring version: spring.boot.start 2.1.3.RELEASE
spring.cloud.start 2.1.1.RELEASE

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>demo-test</groupId>
    <artifactId>demo-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <downloadSources>true</downloadSources>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                 <java.version>1.8</java.version>

        <version.spring.boot>2.1.3.RELEASE</version.spring.boot>
        <version.spring.cloud.starter>2.1.1.RELEASE</version.spring.cloud.starter>
        <version.junit>4.12</version.junit>
    </properties>

    <dependencies>
            <!-- ***** spring boot begin -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
                <version>${version.spring.boot}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${version.spring.boot}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
                <version>${version.spring.boot}</version>
            </dependency>
            <!-- ##### spring boot end -->

            <!-- ***** spring cloud begin -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter</artifactId>
                <version>${version.spring.cloud.starter}</version>
            </dependency>
            <!-- -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-bus-amqp</artifactId>
                <version>${version.spring.cloud.starter}</version>
            </dependency> 

            <!-- ##### spring cloud end -->

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <scope>test</scope>
                <version>${version.junit}</version>
            </dependency>
        </dependencies>

</project>

application.properties:

# =================== 普通 配置 =================== 
# 应用名称
spring.application.name=app
## 应用端口
server.port=9602
# ------- end 以上配置 2.1.3 已失效 
# 可远程关 闭服 务器;默认为 false
management.endpoint.shutdown.enabled=true
# 可远程 重启 服务器;默认为 false
management.endpoint.restart.enabled=true
management.endpoints.web.exposure.include=*

java:

@SpringBootApplication
//@SpringBootApplication(exclude = { BusAutoConfiguration.class })
public class App {

    protected static Logger log = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) {
        log.info("[^_^:20190426-1612-001]=========================================================");
        log.info("[^_^:20190426-1612-001]=== Sprint Cloud App 启动 ... ...");
        log.info("[^_^:20190426-1612-001]=========================================================");
        App.run(args);
        log.info("[^_^:2019201904260416-1612-001]---------------------------------------------------------");
    }

    public static ApplicationContext run(String[] args) {
        SpringApplicationBuilder appCtxBuilder = new SpringApplicationBuilder(App.class);
        // @spencergibb appCtxBuilder = appCtxBuilder.child(MyTestConfig.class);
        SpringApplication app = appCtxBuilder.build();
        return app.run(args);
    }
}

error info:

2019-04-26 20:37:51.872 ERROR 8808 --- [      Thread-11] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: org.springframework.context.annotation.AnnotationConfigApplicationContext@1a84f40f has been closed already
    at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1089) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1213) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.getOrderedBeansOfType(BootstrapApplicationListener.java:329) ~[spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.apply(BootstrapApplicationListener.java:305) ~[spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:120) ~[spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:71) ~[spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    at org.springframework.cloud.context.restart.RestartEndpoint.doRestart(RestartEndpoint.java:133) [spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
    at org.springframework.cloud.context.restart.RestartEndpoint.safeRestart(RestartEndpoint.java:99) [spring-cloud-context-2.1.1.RELEASE.jar:2.1.1.RELEASE]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_172]

2019-04-26 20:37:51.873  INFO 8808 --- [      Thread-11] o.s.c.context.restart.RestartEndpoint    : Could not doRestart: org.springframework.context.annotation.AnnotationConfigApplicationContext@1a84f40f has been closed already

@spencergibb

Comment From: spencergibb

Pasted code isn't helpful to reproduce a problem.

It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Comment From: vinson-bs

Pasted code isn't helpful to reproduce a problem.

It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

The error is reported when the service is restarted using /actuator/restart

Comment From: vinson-bs

Pasted code isn't helpful to reproduce a problem.

It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

In addition, Do not introduction of [ spring-cloud-starter-bus-amqp]; and not use @SpringBootApplication annotation configuration; Use AppCtxBuilder = appCtxBuilder.child (MyTestconfig.class); (MyTestconfig.class adds the @SpringBootApplication annotation.). This way to configure. start and use normally. This error is also reported when restarting the service using /actuator/restart. Use:

appCtxBuilder = appCtxBuilder.parent(MyTestConfig.class);
appCtxBuilder = appCtxBuilder.web(WebApplicationType.SERVLET);

Use "/actuator/restart" to restart the server. no error.

Comment From: vinson-bs

Pasted code isn't helpful to reproduce a problem.

It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

demo-test.zip

start and use "/actuator/restart" to restart the server. Report this error. @spencergibb

Comment From: Haybu

@vinson-bs as documented spring cloud bus implements and supports .../refresh and .../env endpoints only now. I doubt it would work now with .../restart endpoint. @spencergibb or @ryanjbaxter may be able to verify my assumption.

If you include for example (at minimum) spring-cloud-starter, you will be able to restart just fine.

.

Comment From: vinson-bs

Yes, This error occurs when .../restart is used. OK, "bus implements and supports .../refresh and .../env endpoints only now. ". I get it now. @Haybu