org.apache.catalina.core.StandardWrapperValve.invoke 鍦ㄨ矾寰勪负/traffic-web鐨勪笂涓嬫枃涓紝Servlet[spring2]鐨凷ervlet.service锛堬級寮曞彂浜嗗叿鏈夋牴鏈師鍥犵殑寮傚父Filtered request failed.
com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing 'setterless' property ("realmNames"): no way to handle typed deser with setterless yet (through reference chain: org.apache.shiro.subject.SimplePrincipalCollection["realmNames"])
at com.fasterxml.jackson.databind.deser.impl.SetterlessProperty.deserializeAndSet(SetterlessProperty.java:102)
at com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap.findDeserializeAndSet(BeanPropertyMap.java:285)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:248)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:169)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:144)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:124)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:95)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromAny(AsPropertyTypeDeserializer.java:167)
at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserializeWithType(UntypedObjectDeserializer.java:494)
at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:42)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3560)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2709)
问题:Problem deserializing ‘setterless’ property (“realmNames”): no way to handle typed deser with setterless yet (through reference chain: org.apache.shiro.subject.SimplePrincipalCollection[“realmNames”])
提示很清楚,就是shiro的SimplePrincipalCollection类中realmNames字段没有setter方法,没法反序列化。
getter,是由其他字段动态生成的,如下:
public Set<String> getRealmNames() {
if (realmPrincipals == null) {
return null;
} else {
return realmPrincipals.keySet();
}
}
看下redis里面存的值
这个get方法被序列化了,并存到redis了,然后在反序列化的时候,又没有setter,就报了异常
/**
* retemplate相关配置
* 序列化配置
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}