NutzCN Logo
问答 启动项目后访问时BaseModel的字段挨个报不兼容的类型
发布于 1592天前 作者 qq_4ad560c4 1381 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

下面是BaseModel代码

package cn.wizzer.framework.base.model;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.nutz.dao.entity.annotation.*;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;

import java.io.Serializable;

/**
 * Created by wizzer on 2016/6/21.
 */
public abstract class BaseModel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column
    @Comment("操作人")
    @Prev(els = @EL("$me.uid()"))
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String opBy;


    @Column
    @Comment("操作时间")
    @Prev(els = @EL("$me.now()"))
    @ColDefine(type = ColType.INT)
    private Integer opAt;

    @Column
    @Comment("创建人")
    @Prev(els = @EL("$me.uid()"))
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String creater;

    @Column
    @Comment("创建时间")
    @Prev(els = @EL("$me.now()"))
    @ColDefine(type = ColType.INT)
    private Integer createTime;

    @Column
    @Comment("删除标记")
    @Prev(els = @EL("$me.flag()"))
    @ColDefine(type = ColType.BOOLEAN)
    private Boolean delFlag;

    @Column
    @Comment("是否系统初始化数据")//是的话不能删除
    @Default("0")
    @ColDefine(type = ColType.BOOLEAN)
    private Boolean isSystemInit;

    public Boolean getIsSystemInit() {
        return isSystemInit;
    }

    public void setIsSystemInit(Boolean systemInit) {
        isSystemInit = systemInit;
    }

    public String toString() {
        return String.format("/*%s*/%s", super.toString(), Json.toJson(this, JsonFormat.compact()));
    }

    public Boolean flag(){
        return false;
    }

    public Integer now() {
        return (int) (System.currentTimeMillis() / 1000);
    }

    public String uid() {
        try {
            Subject subject = SecurityUtils.getSubject();
            if (subject != null) {
                return Strings.sNull(subject.getSession(true).getAttribute("uid"));
            }
        } catch (Exception e) {
        }
        return "";
    }

    public String getOpBy() {
        return opBy;
    }

    public void setOpBy(String opBy) {
        this.opBy = opBy;
    }

    public Integer getOpAt() {
        return opAt;
    }

    public void setOpAt(Integer opAt) {
        this.opAt = opAt;
    }

    public Boolean getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Boolean delFlag) {
        this.delFlag = delFlag;
    }

    public String uuid() {
        return R.UU32().toLowerCase();
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public Integer getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Integer createTime) {
        this.createTime = createTime;
    }
}

下面是tomcat报错的日志

13-Aug-2020 10:18:01.189 严重 [http-nio-8081-exec-4] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [default] in context with path [] threw exception [Filtered request failed.] with root cause
	java.io.InvalidClassException: cn.wizzer.framework.base.model.BaseModel; incompatible types for field delFlag
		at java.io.ObjectStreamClass.matchFields(ObjectStreamClass.java:2299)
		at java.io.ObjectStreamClass.getReflector(ObjectStreamClass.java:2193)
		at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:669)
		at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1623)
		at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
		at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1623)
		at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
		at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1623)
		at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
		at java.util.HashSet.readObject(HashSet.java:333)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
		at java.util.HashMap.readObject(HashMap.java:1396)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
		at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:501)
		at org.apache.shiro.subject.SimplePrincipalCollection.readObject(SimplePrincipalCollection.java:295)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
		at java.util.HashMap.readObject(HashMap.java:1396)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
		at org.apache.shiro.session.mgt.SimpleSession.readObject(SimpleSession.java:500)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)
		at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:501)
		at net.sf.ehcache.Element.readObject(Element.java:884)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
		at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
		at java.lang.reflect.Method.invoke(Method.java:498)
		at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
		at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1900)
		at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
		at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
		at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
		at net.sf.ehcache.store.disk.DiskStorageFactory.read(DiskStorageFactory.java:371)
		at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:887)
		at net.sf.ehcache.store.disk.Segment.decodeHit(Segment.java:182)
		at net.sf.ehcache.store.disk.Segment.get(Segment.java:225)
		at net.sf.ehcache.store.disk.DiskStore.fault(DiskStore.java:210)
		at net.sf.ehcache.store.CacheStore$4.call(CacheStore.java:198)
		at net.sf.ehcache.store.CacheStore$4.call(CacheStore.java:192)
		at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.get(OnHeapCachingTier.java:334)
		at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.access$200(OnHeapCachingTier.java:311)
		at net.sf.ehcache.store.cachingtier.OnHeapCachingTier.get(OnHeapCachingTier.java:175)
		at net.sf.ehcache.store.CacheStore.get(CacheStore.java:192)
		at net.sf.ehcache.Cache.get(Cache.java:1751)
		at org.apache.shiro.cache.ehcache.EhCache.get(EhCache.java:73)
		at org.apache.shiro.session.mgt.eis.CachingSessionDAO.getCachedSession(CachingSessionDAO.java:217)
		at org.apache.shiro.session.mgt.eis.CachingSessionDAO.getCachedSession(CachingSessionDAO.java:202)
		at org.apache.shiro.session.mgt.eis.CachingSessionDAO.readSession(CachingSessionDAO.java:259)
		at org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSessionFromDataSource(DefaultSessionManager.java:236)
		at org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:222)
		at org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118)
		at org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:108)
		at org.apache.shiro.session.mgt.AbstractNativeSessionManager.getSession(AbstractNativeSessionManager.java:100)
		at org.apache.shiro.mgt.SessionsSecurityManager.getSession(SessionsSecurityManager.java:125)
		at org.apache.shiro.mgt.DefaultSecurityManager.resolveContextSession(DefaultSecurityManager.java:456)
		at org.apache.shiro.mgt.DefaultSecurityManager.resolveSession(DefaultSecurityManager.java:442)
		at org.apache.shiro.mgt.DefaultSecurityManager.createSubject(DefaultSecurityManager.java:338)
		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.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
		at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
		at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:96)
		at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:41002)
		at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
		at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
		at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
		at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
		at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
		at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
		at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
		at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
		at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
		at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
		at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
		at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
		at java.lang.Thread.run(Thread.java:745)

4 回复

mvn clean package install

不行啊,还是报一样的错

存在老版本的pojo类/数据

不存在啊,清了好多回了

添加回复
请先登陆
回到顶部