I'm writing a simple Spring-based web application and deploying it to Websphere Liberty 8.5.5.9; I've gotten past my deployment problems and the application seems to start (according to the Liberty console.log
). However, I'm not seeing any console or log output. My application main class, which contains print statements in the main method, is:
@Configuration
public class UserSettingApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
ServletContext servletContext;
private static final LoggerUtils logger = new LoggerUtils( UserSettingApplication.class );
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
builder.sources(UserSettingApplication.class);
return builder;
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(RequestContextListener.class);
this.servletContext=servletContext;
super.onStartup(servletContext);
}
public static void main(String[] args) throws Exception {
System.out.println( "Entering UserSettingApplication.main" );
SpringApplicationBuilder applicationBuilder = new UserSettingApplication().configure(new SpringApplicationBuilder());
applicationBuilder.run(args);
System.out.println( "Entering UserSettingApplication.main" );
}
@Override
protected WebApplicationContext run(SpringApplication application) {
WebApplicationContext webApplicationContext = super.run(application);
Environment env = webApplicationContext.getEnvironment();
String sessionName = env.getProperty("server.session.cookie.name", "xplore-session-id");
servletContext.getSessionCookieConfig().setName(sessionName);
return webApplicationContext;
}
@Bean
protected RequestContextListener requestContextListener() {
return new RequestContextListener();
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
logger.info("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
logger.info(beanName);
}
};
}
}
Shouldn't I be seeing the print statements in the main method in the WASLiberty console.log
?