你见过不长毛的羊吗

SpringBoot在GlassFish上启动 ContainerBase.addChild: start: org.apache.catalina.LifecycleException

2019.02.13

遇到的问题

在glassfish4.1.2版本中始终无法启动,报错:

Error occurred during deployment: Exception while loading the app :java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: 
org.apache.catalina.LifecycleException: org.springframework.context.ApplicationContextException: 
Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'httpPutFormContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: 
Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.VerifyError: Cannot inherit from final class. 
Please see server.log for more details.

测试了SpringBoot-2.0.5.RELEASE、SpringBoot-2.1.2.RELEASE都有此问题。

解决方法

  1. GlassFish升级到GlassFish5.0就没问题了
  2. 将SpringBoot应用封装成Wrapper服务,再启动。 参考: SpringBoot jar包作为Wrapper服务启动-Linux
    SpringBoot jar包作为Wrapper服务启动-Windows