加载类的时候报序列化问题

阅读更多

 

 

加载类的时候报序列化问题

1,没有实现序列化接口,加序列号

2,服务有实现或继承了序列化接口,子类又实现

2,子类用了toString()

 

添加了一个toString()实现,所以内部的jvm-auto-calculated 

serialVersionUID与之前不同。

 

由于

关键类实现了Externalizable,所以实现也可能会改变一次:

 

3,jvm版本不同

 

 

 

672853 [http-bio-8080-exec-3] WARN  2017-12-05 15:30:07 org.apache.shiro.mgt.DefaultSecurityManager  - Delegate RememberMeManager instance of type [org.apache.shiro.web.mgt.CookieRememberMeManager] threw an exception during getRememberedPrincipals().

org.apache.shiro.io.SerializationException: Unable to deserialze argument byte array.

        at org.apache.shiro.io.DefaultSerializer.deserialize(DefaultSerializer.java:82)

        at org.apache.shiro.mgt.AbstractRememberMeManager.deserialize(AbstractRememberMeManager.java:514)

        at org.apache.shiro.mgt.AbstractRememberMeManager.convertBytesToPrincipals(AbstractRememberMeManager.java:431)

        at org.apache.shiro.mgt.AbstractRememberMeManager.getRememberedPrincipals(AbstractRememberMeManager.java:396)

        at org.apache.shiro.mgt.DefaultSecurityManager.getRememberedIdentity(DefaultSecurityManager.java:604)

        at org.apache.shiro.mgt.DefaultSecurityManager.resolvePrincipals(DefaultSecurityManager.java:492)

        at org.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:342)

        at org.apache.shiro.subject.Subject$Builder.buildSubject(Subject.java:846)

        at org.apache.shiro.web.subject.WebSubject$Builder.buildWebSubject(WebSubject.java:148)

        at org.apache.shiro.web.servlet.AbstractShiroFilter.createSubject(AbstractShiroFilter.java:292)

        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:359)

        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)

        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

        at com.common.CrossDomainFilter.doFilter(CrossDomainFilter.java:62)

        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)

        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)

        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)

        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

 

       at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.ClassNotFoundException: Unable to load ObjectStreamClass [[Lcore.apps.rbac.vo.FlexGrantedAuthority;: static final long serialVersionUID = 7325751928510350430L;]: 

        at org.apache.shiro.io.ClassResolvingObjectInputStream.resolveClass(ClassResolvingObjectInputStream.java:55)

        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1868)

        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1751)

        at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1930)

 

 

 

处理方式:例如去了toString()方法

 

 

package core.apps.rbac.vo;

import core.apps.rbac.entity.SkillInfoEntity;
import org.acegisecurity.GrantedAuthority;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class FlexGrantedAuthority
  implements GrantedAuthority
{


  private static final long serialVersionUID = -2626208595738823534L;
  private String role;
  private List skillUrls = new ArrayList();

  public List getSkillUrls()
  {
    return this.skillUrls;
  }

  public void setSkillUrls(List skillUrls) {
    this.skillUrls = skillUrls;
  }

  public String getRole() {
    return this.role;
  }

  public void setRole(String role) {
    this.role = role;
  }

  public String getAuthority()
  {
    return this.role;
  }
  //public String toString()
  //{
   // return this.role;
 //}

}

 

 

 

 

参考:

http://grokbase.com/t/shiro/user/09b4h1afs0/serializationexception

 

 

 

你可能感兴趣的:(shiro)