简体   繁体   中英

Spring Boot initialization not completing [Application stuck]

While starting the Spring boot, application gets stuck and SpringApplication.run is not returning.

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class AccountServiceApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(AccountServiceApplication.class, args);
        System.out.println("----------------------------- I'm done -------------------------");
    }
}

I can see that Spring creates all the beans but it never returns, though embedded tomcat is started on 9000, it's not listening

class org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory's object [after] tomcatEmbeddedServletContainerFactory
[05/16/19 06:17:44:044 IST]  INFO tomcat.TomcatEmbeddedServletContainer: : Tomcat initialized with port(s): 9000 (http)
May 16, 2019 6:17:44 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-9000"]
May 16, 2019 6:17:44 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Trying 127.0.0.1...
Connection failed: Connection refused
Trying ::1...
telnet: Unable to connect to remote host: Connection refused

Application is stuck forever post creating JMS connection.

class org.springframework.expression.spel.support.StandardEvaluationContext's object [after] integrationEvaluationContext
class org.springframework.integration.handler.LoggingHandler's object [after] _org.springframework.integration.errorLogger.handler
class org.springframework.integration.config.ConsumerEndpointFactoryBean's object [before]_org.springframework.integration.errorLogger
class org.springframework.integration.config.ConsumerEndpointFactoryBean's object [after] _org.springframework.integration.errorLogger
class org.springframework.integration.config.IdGeneratorConfigurer's object [before]org.springframework.integration.config.IdGeneratorConfigurer#0
class org.springframework.integration.config.IdGeneratorConfigurer's object [after] org.springframework.integration.config.IdGeneratorConfigurer#0
[05/16/19 05:58:02:002 IST]  INFO annotation.AnnotationMBeanExporter: : Registering beans for JMX exposure on startup
class org.springframework.expression.spel.support.StandardEvaluationContext's object [after] integrationEvaluationContext
[05/16/19 05:58:02:002 IST]  INFO support.DefaultLifecycleProcessor: : Starting beans in phase 0
[05/16/19 05:58:02:002 IST]  INFO endpoint.EventDrivenConsumer: : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
[05/16/19 05:58:02:002 IST]  INFO channel.PublishSubscribeChannel: : Channel 'application:9000.errorChannel' has 1 subscriber(s).
[05/16/19 05:58:02:002 IST]  INFO endpoint.EventDrivenConsumer: : started _org.springframework.integration.errorLogger
[05/16/19 05:58:02:002 IST]  INFO support.DefaultLifecycleProcessor: : Starting beans in phase 2147483647
[05/16/19 05:58:02:002 IST]  INFO connection.CachingConnectionFactory: : Established shared JMS Connection: ActiveMQConnection {id=ID:SDSD121SFSSDF.local-54305-1557966482134-1:1,clientId=null,started=false}

Any pointer on how can I debug it?

in your application,it may be exist a thread with an infinite loop. your application start up fail. and this thread is not quit. the process still is exist.it looks like start up successfully.

The common practice that might help in such cases is to " catch the lion in the desert / binary search " for the cause the problem.

Try comment out halves of your application till you reach a point where the application starts with no problem. Then you will be able to nail the problematic code/section.

I also got stuck at :

INFO support.DefaultLifecycleProcessor: : Starting beans in phase X

It was because in a @RestController class I made a @GetMapping method return a @Entity, where it should have been a DTO instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM