Reputation: 1318
I have a Spring Boot application that uses Spring Integration to do some SFTP polling...
I am trying to follow this guide to package a jar file and deploy it as a war file to a wildfly 8.2 application server. I am using a gradle plugin that only allows the deploy of war or ear files.
So in my attempt to have this done I run locally with embedded tomcat, and it works flawlessly, but when I test it remotely then the app is deployed but never started.
@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);
}
}
Logs from 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")
Why is the main not starting when in Wildfly?!
Upvotes: 0
Views: 1224
Reputation: 1318
I removed the extentions of SpringBootServletInitializer, my main and co nfigure methods and added this method instead. It now starts up.
@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);
}
Upvotes: 0
Reputation: 116301
It's the configure
method that's used when launching a Spring Boot app in an app server. The main
method is only used when you launch the app as an executable archive using java -jar
.
Upvotes: 1