android-priority-jobqueue icon indicating copy to clipboard operation
android-priority-jobqueue copied to clipboard

Cannot save job to disk too

Open zhujin001032 opened this issue 7 years ago • 3 comments

Please help me, Thanks! Error message: E/AndroidRuntime: FATAL EXCEPTION: job-manager Process: com.vuspex.contractor.dev, PID: 28302 java.lang.RuntimeException: cannot save job to disk at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.persistJobToDisk(SqliteJobQueue.java:107) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.insert(SqliteJobQueue.java:90) at com.birbit.android.jobqueue.cachedQueue.CachedJobQueue.insert(CachedJobQueue.java:29) at com.birbit.android.jobqueue.JobManagerThread.handleAddJob(JobManagerThread.java:143) at com.birbit.android.jobqueue.JobManagerThread.access$100(JobManagerThread.java:35) at com.birbit.android.jobqueue.JobManagerThread$1.handleMessage(JobManagerThread.java:228) at com.birbit.android.jobqueue.messaging.PriorityMessageQueue.consume(PriorityMessageQueue.java:39) at com.birbit.android.jobqueue.JobManagerThread.run(JobManagerThread.java:222) at java.lang.Thread.run(Thread.java:762) Caused by: java.io.NotSerializableException: com.vuspex.contractor.common.ScheduleInspectionJob$1 at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue$JavaSerializer.serialize(SqliteJobQueue.java:493) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.persistJobToDisk(SqliteJobQueue.java:105) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.insert(SqliteJobQueue.java:90)  at com.birbit.android.jobqueue.cachedQueue.CachedJobQueue.insert(CachedJobQueue.java:29)  at com.birbit.android.jobqueue.JobManagerThread.handleAddJob(JobManagerThread.java:143)  at com.birbit.android.jobqueue.JobManagerThread.access$100(JobManagerThread.java:35)  at com.birbit.android.jobqueue.JobManagerThread$1.handleMessage(JobManagerThread.java:228)  at com.birbit.android.jobqueue.messaging.PriorityMessageQueue.consume(PriorityMessageQueue.java:39)  at com.birbit.android.jobqueue.JobManagerThread.run(JobManagerThread.java:222)  at java.lang.Thread.run(Thread.java:762)  D

This is my Job class:

public class ScheduleInspectionJob extends Job {

transient private Appointments appointments;
transient private String upload_link_secure;
transient private String complete_uri;
transient private String location = "";

transient private ArrayList<PhotoVideo> videoArrayList;
transient private ArrayList<PhotoVideo> photoArrayList;
transient private ArrayList<PhotoVideo> uploadedArrayList;
transient public int photoTotal;
transient public int videoTotal;
transient public int photoFailTotal = 0;
transient public int photoSuccessTotal = 0;
transient public int videoSuccessTotal = 0;
public int appointmentsId;


public ScheduleInspectionJob(int appointmentsId) {
    super(new Params(1).persist().requireNetwork().groupBy("appointments"));
    this.appointmentsId = appointmentsId;
}

@Override
public void onAdded() {
    //job has been secured to disk, add item to database
}

@Override
public void onRun() throws Throwable {
        //query from database
        this.appointments = Appointments.queryAppointmentsWithApId(appointmentsId);
        photoTotal = 0;
        videoTotal = 0;
        photoFailTotal = 0;
        photoSuccessTotal = 0;
        videoSuccessTotal = 0;
        upload_link_secure = "";
        complete_uri = "";
        location = "";

        videoArrayList = new ArrayList<>();
        photoArrayList = new ArrayList<>();
        uploadedArrayList = new ArrayList<>();
        ......... ........

}

zhujin001032 avatar Jan 11 '18 07:01 zhujin001032

This is strange. Do you have any other field in your ScheduleInspectionJob which is not declared as transient other than appointmentsId?

kalpeshp0310 avatar Jan 26 '18 17:01 kalpeshp0310

Thanks for you reply, I'am sure only the appointmentsId filed not declared as transient.

zhujin001032 avatar Feb 28 '18 05:02 zhujin001032

I guess you have anonymous inner class ScheduleInspectionJob $1 in your ScheduleInspectionJob which is not serializable. You can refer this stackoverflow question to investigate more. https://stackoverflow.com/a/32411875/1282812

kalpeshp0310 avatar Feb 28 '18 15:02 kalpeshp0310