alibaba / fastjson

FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
https://github.com/alibaba/fastjson2/wiki/fastjson_1_upgrade_cn
Apache License 2.0
25.76k stars 6.5k forks source link

使用fastjson序列化数据时,ASM报java.lang.NoSuchMethodError: com.alibaba.fastjson.serializer.JavaBeanSerializer.processValue #2780

Open helloworldtang opened 5 years ago

helloworldtang commented 5 years ago

背景介绍:

代码:一段几个月前的老代码 变更: 将fastjson从1.2.57升级到1.2.61

异常堆栈:

java.lang.NoSuchMethodError: com.alibaba.fastjson.serializer.JavaBeanSerializer.processValue(Lcom/alibaba/fastjson/serializer/JSONSerializer;Lcom/alibaba/fastjson/serializer/BeanContext;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;Ljava/lang/Integer;
    at com.alibaba.fastjson.serializer.ASMSerializer_1_CurrentUserBO.writeNormal(Unknown Source) ~[na:na]
    at com.alibaba.fastjson.serializer.ASMSerializer_1_CurrentUserBO.write(Unknown Source) ~[na:na]
    at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:285) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.JSON.toJSONBytes(JSON.java:825) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.JSON.toJSONBytes(JSON.java:796) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.JSON.toJSONBytes(JSON.java:789) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.JSON.toJSONBytes(JSON.java:771) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.JSON.toJSONBytes(JSON.java:698) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.JSON.toJSONBytes(JSON.java:687) ~[fastjson-1.2.61.jar:na]
    at com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer.serialize(GenericFastJsonRedisSerializer.java:24) ~[fastjson-1.2.61.jar:na]
    at org.springframework.data.redis.core.AbstractOperations.rawValue(AbstractOperations.java:117) ~[spring-data-redis-1.8.12.RELEASE.jar:na]
    at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:180) ~[spring-data-redis-1.8.12.RELEASE.jar:na]
    at com.user.app.cache.impl.UserCacheServiceImpl.cacheCurrentLoginUser(UserCacheServiceImpl.java:48) ~[classes/:na]
    at com.user.app.service.impl.LoginServiceImpl.tokenLogin(LoginServiceImpl.java:112) ~[classes/:na]
    at com.user.app.service.impl.LoginServiceImpl.mobileLogin(LoginServiceImpl.java:86) ~[classes/:na]
    at com.user.app.service.impl.MobileLoginServiceImpl.login(MobileLoginServiceImpl.java:51) ~[classes/:na]
    at com.user.app.controller.AppUserController.login(AppUserController.java:130) ~[classes/:na]
    at com.user.app.controller.AppUserController$$FastClassBySpringCGLIB$$7dc4b154.invoke(<generated>) ~[classes/:na]

相关的java代码:

    @Override
    public void cacheCurrentLoginUser(Integer userId, Integer sourceType, String mobile, Integer invoiceInfoId) {
        CurrentUserBO currentUserBO = new CurrentUserBO();
        currentUserBO.setMobile(mobile);
        currentUserBO.setInvoiceId(invoiceInfoId);
        String key = CacheKeyManager.fillKey(CURRENT_USER_KEY, userId, sourceType);
        redisTemplate.opsForValue().set(key, currentUserBO, COOKIE_MAX_AGE, TimeUnit.SECONDS); //此行代码报错
    }

RedisTemplate中FastJsonRedisSerializer的使用:

    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);//设置默认的Serialize,包含 keySerializer & valueSerializer
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        return redisTemplate;
    }

涉及到的BO:

import lombok.Data;

/**
 * @Description:
 */
@Data
public class CurrentUserBO {

    /**
     * 抬头Id
     */
    private Integer invoiceId;

    /**
     * userId和invoiceId关联的手机号
     */
    private String mobile;

}

image

Omega-Ariston commented 5 years ago

Duplicate of #2763

kervin521 commented 5 years ago

同样问题

zwy20034751 commented 5 years ago

同样问题

zhaotingwen commented 5 years ago

升级到1.2.62时还是会报这个错误呢。 java.lang.NoSuchMethodError: com.alibaba.fastjson.serializer.JavaBeanSerializer.processValue(Lcom/alibaba/fastjson/serializer/JSONSerializer;Lcom/alibaba/fastjson/serializer/BeanContext;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;Ljava/lang/Integer; at com.alibaba.fastjson.serializer.ASMSerializer_1_GetAvailabilityByFlightRequestBean.writeNormal(Unknown Source) ~[na:na] at com.alibaba.fastjson.serializer.ASMSerializer_1_GetAvailabilityByFlightRequestBean.write(Unknown Source) ~[na:na] at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:271) ~[fastjson-1.2.62.jar:na] at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:44) ~[fastjson-1.2.62.jar:na] at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:271) ~[fastjson-1.2.62.jar:na] at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:44) ~[fastjson-1.2.62.jar:na] at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:285) ~[fastjson-1.2.62.jar:na]

helloworldtang commented 5 years ago

@zhaotingwen 1.2.62还有这个问题.温少让Nameless·Ariston找我修过了。 我这边环境的兼容性问题已修复。

现在坐等@wenshao发版

zhangxuexiang commented 5 years ago

预计什么时候可以修复这个问题

zwy20034751 commented 5 years ago

坐等发版

kervin521 commented 5 years ago

+1

kakukeme commented 5 years ago

+1

kasuo405 commented 5 years ago

+1

yuh-efan commented 5 years ago

waiting...

woodyDM commented 5 years ago

在windows下会报这个错,在macOS 和 ubuntu下不会。

oyl215 commented 5 years ago

升级到1.2.62版本仍然存在这个问题,老的版本不存在这个问题,期待这个问题的解决。

DayBreakOb commented 5 years ago

how to solve it.

Liuliya503288309 commented 5 years ago

新版本怎么解决这个问题呢

rainofflower commented 5 years ago

在windows下会报这个错,在macOS 和 ubuntu下不会。

centos7也不会报错,windows10下确实报错

FikaCode commented 5 years ago

@13438344431 return to 1.2.58 @Liuliya503288309 退回 1.2.58 ,我这边正常了。

wang420979002 commented 5 years ago

1.2.62 win10报错,求下个版本解决

hct7511 commented 5 years ago

1.2.58解决。。

kervin521 commented 5 years ago

v1.2.60也是正常的

helloworldtang commented 5 years ago

@13438344431 return to 1.2.58 @Liuliya503288309 退回 1.2.58 ,我这边正常了。

1.2.58有漏洞哦

helloworldtang commented 5 years ago

1.2.58解决。。

1.2.58有漏洞哦

helloworldtang commented 5 years ago

v1.2.60也是正常的

1.2.60有安全隐患哦

FikaCode commented 5 years ago

@helloworldtang 只有等作者修复,换jackson代价太大了....

gchhy commented 4 years ago

the same question

yechen2 commented 4 years ago

the same question

lyyu1988 commented 4 years ago

the same question

samuel072 commented 4 years ago

V1.2.60版本好, 但是以上的版本都不行。系统:mac V:10.15, 暂时还不知道在centos是否有问题。但是有的兄弟说这个版本不能在centos系统使用。

llliuwenjie commented 4 years ago

mac系统也报错 1.2.62

thinkbig2021 commented 4 years ago

mac系统也报错 1.2.62,看到有说win10,mac操作系统版本不同还报错的,好神奇

qrqhuang commented 4 years ago

same behaviour

412940226 commented 4 years ago

win10系统1.2.62有问题,请问修复了没有 java.lang.NoSuchMethodError: com.alibaba.fastjson.serializer.JavaBeanSerializer.processValue

wmwmwmll commented 4 years ago

how to solve

412940226 commented 4 years ago

how to solve

Win10 still has problems

zyong2004 commented 4 years ago

同样的问题,win10出问题

faliny commented 4 years ago

mark一下,等待修复

morpheus-1997 commented 4 years ago

马一下,等待修复

niaonao commented 4 years ago

先降版本吧

eyougo commented 4 years ago

1.2.62,Mac系统,还是这个问题,求修复

yushilin commented 4 years ago

诺诺的问一句,还没有修复么?

yguilai commented 4 years ago

诺诺的问一句,还没有修复么?

我升到1.2.66 没报这个错了

Miven666 commented 4 years ago

我升到1.2.66 也没报这个错了 Mac 10.15.3

flibbertigibbet-Y commented 4 years ago

So???要升级到1.2.66才行咯??

xctjtcc commented 2 months ago

@zhaotingwen 1.2.62还有这个问题.温少让Nameless·Ariston找我修过了。 我这边环境的兼容性问题已修复。

能否分享下具体情况?是和什么发生冲突了呢,怎么解决的?

yushilin commented 2 months ago

邮件已经收到,谢谢!!!

DayBreakOb commented 2 months ago

'你好。已收到你的邮件,我会在假期结束后尽快处理。————————————这是来自QQ邮箱的自动回复邮件。'