OOM异常简析

今天虚拟机报出OOM异常,异常代码如下

[ERROR] GlobalExceptionHandler - java.lang.OutOfMemoryError: GC overhead limit exceeded - [cn.bidlink.framework.core.exceptions.GlobalExceptionHandler]
java.lang.RuntimeException: java.lang.OutOfMemoryError: GC overhead limit exceeded
at cn.bidlink.framework.dao.ibatis.interceptor.DaoInterceptor.doException(DaoInterceptor.java:36)
at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy.intercept(Cglib2AopProxy.java:622)
at cn.bidlink.ebnew.bizpurchaseproduct.dao.impl.BizPurchaseProductDaoImpl.findByCondition(<generated>)
at cn.bidlink.ebnew.buyer.service.impl.BizPurchaseProductServiceImpl.findBizPurchaseProducts(BizPurchaseProductServiceImpl.java:45)
at cn.bidlink.ebnew.buyer.service.impl.BizPurchaseProductServiceImpl.invoke(<generated>)

寻找原因:

看到OutOfMemoryError,起初认为是虚拟机内存不足导致,于是加了虚拟机内存发现还是异常还是存在,本地运行发现商机对象有一个BigDecimal类型字段反序列化后为空字符串,库里却有值,查看Mybatis对应Mapper文件发现,为空时查询的是表所有数据,导致内存溢出。

解决问题:

查询得知hessian-4.0.7.jar版本无法正确传输BigDecimal问题。

比如需要hessian传输BigDecimal类型数据“10.01”。但经传输后得到的数值却为“0”。
经查找网络相关资料问题得到了解决,详见下文的“最佳解决办法”

 

hessian官网

http://hessian.caucho.com/#Java

后来下载了http://hessian.caucho.com/download/hessian-4.0.37.jar

并与原有hessian-4.0.7.jar版本进行了对比,发现“hessian-4.0.37.jar”中已经进行了此问题的修复,并且修复方法也和下文的“最佳解决办法”一致。

 


hessian-4.0.7.\META-INF\hessian中是没有“deserializers”、“serializers”两文件的。

而“hessian-4.0.37.jar”中已经增加了此两文件

 

 

解决Hessian不能正确传输BigDecimal问题

Hessian不能正确传输BigDecimal,解决方法:指定系列化类。


增加下面两个文件,打入hessian包。

/META-INF/hessian/serializers,内容如下:

java.math.BigDecimal=com.caucho.hessian.io.BigDecimalDeserializer


/META-INF/hessian/deserializers

java.math.BigDecimal=com.caucho.hessian.io.StringValueSerializer

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值