DeferredTask always gives NotSerialisable exception

69 views
Skip to first unread message

Deepak Singh

unread,
Apr 7, 2012, 4:33:42 PM4/7/12
to google-a...@googlegroups.com, objectify...@googlegroups.com
Hi,

I am doing some database operation on GAE-JAVA using Objectify 3.0.1 through Deferedtask as follows,

 class TaskOp implements DeferredTask, Serializable {

@Override
public void run() {
try{
enq.setStatus(Constant.CANCELLED_ENQUIRY);
objectify.put(enq);
List<PackageConversationDTO> convList = objectify.query(PackageConversationDTO.class).filter("leadId", enq.getId()).list();
for(PackageConversationDTO convDto : convList) {
convDto.setStatus(Constant.CANCELLED_TRIP_PACKAGE_CONVERSATION);
objectify.put(convDto);
}
List<HolidayInvoiceDTO> list = objectify.query(HolidayInvoiceDTO.class).filter("tripId", enq.getId()).list();
for(HolidayInvoiceDTO holiday : list) {
holiday.setStatus(Constant.INVOICE_GENERATED_THEN_TRIP_CANCELLED);
objectify.put(holiday);
}
}catch (Exception e) {
System.out
.println("CommonRpcServiceImpl.cancelTripEnquiry(...).TaskOp.run() "+e.getMessage());
}
}
 

           

               try{
TaskOptions taskOpt = TaskOptions.Builder.withPayload(new TaskOp());
Queue defQueue = QueueFactory.getDefaultQueue();
defQueue.add(taskOpt);
}catch (Exception e) {
System.out.println("CommonRpcServiceImpl.cancelTripEnquiry() "+e.getMessage());
}

It always throws this exception

CommonRpcServiceImpl.cancelTripEnquiry() java.io.NotSerializableException: com.google.gwt.user.server.rpc.impl.StandardSerializationPolicy

I make sure that all the object being used here are serializable.


Thanks in advance 
Deepak Singh

Deepak Singh

unread,
Apr 8, 2012, 7:04:04 PM4/8/12
to google-a...@googlegroups.com, objectify...@googlegroups.com
I am still stuck with the issue....
--
Deepak Singh

Jeff Schnitzer

unread,
Apr 8, 2012, 8:59:55 PM4/8/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
I suggest restating the problem and being as clear as possible. I
can't understand what you are asking - sorry.

Jeff

Deepak Singh

unread,
Apr 9, 2012, 5:13:16 AM4/9/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
Hi Jeff,
 
I create an inner class as follows,
 
class TaskOp implements DeferredTask, Serializable {

   @Override
   public void run() {
    try{
    enq.setStatus(Constant.CANCELLED_ENQUIRY);
    objectify.put(enq);
}catch () {
 
}
}
}
 
Here in run method, i am using objectify.put('a serialisable object');
Now i create a taskOption as follows,
 
 try{
  TaskOptions taskOpt = TaskOptions.Builder.withPayload(new TaskOp());
  Queue defQueue = QueueFactory.getDefaultQueue();
  defQueue.add(taskOpt);
  }catch (Exception e) {
   System.out.println("CommonRpcServiceImpl.cancelTripEnquiry() "+e.getMessage());
  }
 
Here the task option accepts an object of my inner class which implements DeferreTask.
 
Now executing the above task gives me the following exception,
 
 java.io.NotSerializableException: com.google.gwt.user.server.rpc.impl.StandardSerializationPolicy
 
I verify that the object being used in DeferredTask is serialisable, even the i am getting the exception.
 
I hope now the problem is clear.
 
 
 
Thanks
Deepak
--
Deepak Singh

Jeff Schnitzer

unread,
Apr 9, 2012, 11:44:13 AM4/9/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
The key phrase is "inner class". You probably aren't making the inner
class static. Remember that java inner classes contain an implicit
reference to their containing class - so you're trying to serialize
bot the inner class and the outer class.

Jeff

Deepak Singh

unread,
Apr 15, 2012, 2:12:01 PM4/15/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
I made my inner class as static but still got the same error.
--
Deepak Singh

Deepak Singh

unread,
Apr 17, 2012, 6:25:38 PM4/17/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
Still no luck. is it a problem with Objectify ?
--
Deepak Singh

Jeff Schnitzer

unread,
Apr 17, 2012, 7:57:20 PM4/17/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
On Tue, Apr 17, 2012 at 6:25 PM, Deepak Singh <deepaks...@gmail.com> wrote:
> Still no luck. is it a problem with Objectify ?

That is extraordinarily unlikely.

You'll have to post a lot more code if you want help.

Jeff

Deepak Singh

unread,
Apr 25, 2012, 1:22:29 PM4/25/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
Hi Jeff,

Here is the complete code:

here is my static inner class,

public static class CancelTriptaskOperation implements DeferredTask, Serializable {

private PackageEnqFormDTO enq = null;
Objectify objectifyDeferred = ObjectifyService.begin();

public CancelTriptaskOperation(final PackageEnqFormDTO enq1) {
this.enq = enq1;
}

@Override
public void run() {
try{
enq.setStatus(YFConstant.CANCELLED_ENQUIRY);
LinkedHashMap<String, PackageConversationDTO> convMap = enq.getLeadAndConvMap();
Set<String> keys = convMap.keySet();
Iterator<String> itr = keys.iterator();
while(itr.hasNext()) {
String key = itr.next();
PackageConversationDTO convDto = convMap.get(key);
convDto.setStatus(YFConstant.CANCELLED_TRIP_PACKAGE_CONVERSATION);
convMap.put(key, convDto);
}
objectifyDeferred.put(enq);
List<HolidayInvoiceDTO> list = objectifyDeferred.query(HolidayInvoiceDTO.class).filter("tripId", enq.getId()).list();
for(HolidayInvoiceDTO holiday : list) {
holiday.setStatus(YFConstant.INVOICE_GENERATED_THEN_TRIP_CANCELLED);
objectifyDeferred.put(holiday);
}
}catch (Exception e) {
System.out.println("CommonRpcServiceImpl.TaskOp.run() "+e.getMessage());
}
}

}


Here is my method in outer class:

@Override
public boolean cancelTripEnquiry(final PackageEnqFormDTO enq) {
try{
TaskOptions taskOpt = TaskOptions.Builder.withPayload(new CancelTriptaskOperation(enq));
Queue defQueue = QueueFactory.getDefaultQueue();
defQueue.add(taskOpt);
}catch (Exception e) {
System.out.println("CommonRpcServiceImpl.cancelTripEnquiry() "+e.getMessage());
}
return true;
}



Hope the code is understandable.


Thanks
Deepak

--
Deepak Singh

Deepak Singh

unread,
Apr 25, 2012, 1:28:14 PM4/25/12
to objectify...@googlegroups.com, google-a...@googlegroups.com
Hi Jeff,

In continuation to the previous mail,

I am getting the following exception:

CommonRpcServiceImpl.cancelTripEnquiry() java.io.NotSerializableException: com.googlecode.objectify.impl.ObjectifyImpl


Thanks
Deepak
--
Deepak Singh
Reply all
Reply to author
Forward
0 new messages