Wildfly не запускает развертываемый военный файл

У меня есть приложение Spring Boot, которое использует Spring Integration для опроса SFTP...

Я пытаюсь следовать этому руководству, чтобы упаковать JAR-файл и развернуть его как военный файл на сервере приложений wildfly 8.2. Я использую плагин Gradle, который позволяет развертывать только файлы war или ear.

Итак, в моей попытке сделать это я запускаю локально со встроенным tomcat, и он работает безупречно, но когда я тестирую его удаленно, приложение развертывается, но никогда не запускается.

@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Stasher extends SpringBootServletInitializer implements WebApplicationInitializer {

private static Class<Stasher> applicationClass = Stasher.class;

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
         return application.sources(applicationClass);
    }


    public static void main(String[] args) {
        System.out.println("MAIN STARTED ***************************");
        SpringApplication.run(Stasher.class, args);
    }
}

Журналы Wildfly 8.2

19:12:35,347 INFO  [org.springframework.jmx.export.annotation.AnnotationMBeanExporter] (MSC service thread 1-4) Registering beans for JMX exposure on startup
19:12:35,352 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (MSC service thread 1-4) Starting beans in phase -2147483648
19:12:35,353 INFO  [org.springframework.context.support.DefaultLifecycleProcessor] (MSC service thread 1-4) Starting beans in phase 0
19:12:35,353 INFO  [org.springframework.integration.endpoint.EventDrivenConsumer] (MSC service thread 1-4) Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
19:12:35,353 INFO  [org.springframework.integration.channel.PublishSubscribeChannel] (MSC service thread 1-4) Channel 'Stasher-Default.errorChannel' has 1 subscriber(s).
19:12:35,353 INFO  [org.springframework.integration.endpoint.EventDrivenConsumer] (MSC service thread 1-4) started _org.springframework.integration.errorLogger
19:12:35,359 INFO  [org.springframework.boot.SpringApplication] (MSC service thread 1-4) Started application in 1.695 seconds (JVM running for 11619.131)
19:12:35,361 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017534: Registered web context: /Stasher
19:12:35,439 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "Stasher.war" (runtime-name : "Stasher.war")

Почему не запускается главное в Wildfly?!


person Jes Chergui    schedule 18.05.2015    source источник


Ответы (2)


Это метод configure, который используется при запуске приложения Spring Boot на сервере приложений. Метод main используется только при запуске приложения в виде исполняемого архива с использованием java -jar.

person Andy Wilkinson    schedule 18.05.2015

Я удалил расширения SpringBootServletInitializer, моих методов main и configure и вместо этого добавил этот метод. Теперь он запускается.

@Override
public void onStartup(ServletContext container) {
    ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext.xml");
    PollableChannel ftpChannel = context.getBean("ftpChannel", PollableChannel.class);
    Message<?> message = ftpChannel.receive();

    System.out.println("Received message: " + message);
}
person Jes Chergui    schedule 18.05.2015