升级log4j2,tomcat--7.0.16 启动就OOM,蛋疼的问题

升级log4j2 ,官网说要web.xml里的<web-app> version 属性改成3.0,发现改了之后,一起动就报错OOM,

Exception in thread "main" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"


发现改成2.5就没事:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  version="2.5"

  >  


,或者加一个属性  metadata-complete=true 也没事:

  <web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"
  metadata-complete="true"
  >  


或者,换成 tomcat-7.0.81也没事,

真是日了狗了,这种问题网上没答案 只有靠自己研究了,折腾了好长时间


这个属性的作用如下:

Attribute : metadata-complete
The metadata-complete attribute defines whether this deployment descriptor and other related 
 deployment descriptors for this module (e.g., web service descriptors) are complete, or whether the 
 class files available to this module and packaged with this application should be examined for 
 annotations that specify deployment information. If metadata-complete is set to "true", the 
 deployment tool must ignore any annotations that specify deployment information, which might be 
 present in the class files of the application. If metadata-complete is not specified or is set to "false", 
 the deployment tool must examine the class files of the application for annotations, as specified by 
 the specifications.



猜测 是 2.5 没有采用java注解配置servlet,listener,filter....的特性,tomcat--7.0.16不会扫描java类的class,version=3.0 加上一个metadata-complete=true  属性也能阻止扫描

改成3.0  tomcat--7.0.16就会去扫描这些有servlet注解的 class,可能在这个过程中导致了OOM

而 tomcat--7.0.81 可能修复了这个问题



好复杂。。。。。。。。。。。。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值