Spring Boot war file on tomcat: errorPageFilter cannot be cast to TomcatEmbeddedServletContainerFactory

后端 未结 2 1871
旧巷少年郎
旧巷少年郎 2021-01-20 23:14

I\'m trying to convert a simple Spring Boot app into a war file for deployment to my tomcat server but I keep on getting this error:

Caused by: org.springframewo         


        
相关标签:
2条回答
  • 2021-01-20 23:22

    Why are your trying to configure embedded Tomcat when you want to deploy it on external container? I had similar problem and what finally worked for me was to completely exclude tomcat starter from the project dependencies. Since spring-boot-starter-tomcat is dependency of spring-boot-starter-web use something like this:

    compile ('org.springframework.boot:spring-boot-starter-web') {
        exclude module: 'spring-boot-starter-tomcat'
    }
    

    And, of course, delete line that explicitly imports spring-boot-starter-tomcat (it's not needed, even in embedded mode).

    You may have a problem if you want your app to be deployable in both ways - I didn't have to worry about this in my case.

    0 讨论(0)
  • 2021-01-20 23:29

    You're trying to customize SSL connections with your customizer. It's 100% legal if you are launching embedded tomcat server. So the flow is the following:

    • you customize tomcat setup
    • you launch the server

    From the JavaDocs of EmbeddedServletContainerCustomizer

    Strategy interface for customizing auto-configured embedded servlet containers. Any beans of this type will get a callback with the container factory before the container itself is started, so you can set the port, address, error pages etc.

    Contrary, you cannot customize any of those things on already running tomcat.

    Imagine what kind of security issues you could face if you had an option to change port / address of already running tomcat with just deploying a war file to it.

    If you really need to customize the ssl connectors you need to go deep into xml configurations of tomcat.

    A great and simple guide can be found here

    0 讨论(0)
提交回复
热议问题