1

OpenLiberty 18.0.0.3 supports automatic disabling of the embedded Tomcat Container. However, this does not appear to work when the SpringBoot application contains an EmbeddedServletContainerFactory @Bean in the SpringBoot application class.

How can this EmbeddedServletContainerFactory @Bean be disabled using external configuration/xml file or other, so that Liberty can override the embedded container?

package com.mw.springboot.jaxws;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class SpringCxfApplication {

  public static void main(String[] args) {


    SpringApplication.run(SpringCxfApplication.class, args);
  }


  // Register Servlet
  @Bean
  public ServletRegistrationBean servletRegistrationBean() {
    ServletRegistrationBean bean = new ServletRegistrationBean(new MyServlet(), "/myServlet");
    return bean;
  }

  // how can this be disabled through external configuration?  
  @Bean
  public EmbeddedServletContainerFactory servletContainer() {
      TomcatEmbeddedServletContainerFactory factory = 
                    new TomcatEmbeddedServletContainerFactory();
      return factory;
   }


}

The following errors are reported:

88856 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase
: A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[/path]] at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_144]

0 Answers0