1
votes

I'm trying to return an arrayList from my mysql database to use in a GWT cellList, but I'm running into a serialization issue.

Type 'com.cbs.ioma.client.Order' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = Order [orderNumber=1001, orderer=test, assembler=1, dateCompleted=1969-12-31, dateSubmitted=1969-12-31, notes=rer, isComplete=false, type=erer]

I have a class Order, but when i try and change it to

public class Order implements java.io.Serializable

the program crashes and no error is message is displayed. I don't know a lot about serialization inside of GWT so how would I go about serializing a class to use in GWT? I have the correct function names in the service and serviceAync class I believe. thanks.

Edit: I'll add a little more here. I tried changing the order class to implement isSerializable and then I get this error

12:55:49.793 [ERROR] [ioma] Uncaught exception escaped

java.lang.ClassCastException: com.cbs.ioma.client.Order cannot be cast to java.lang.String at com.google.gwt.text.shared.SimpleSafeHtmlRenderer.render(SimpleSafeHtmlRenderer.java:1) at com.google.gwt.cell.client.AbstractSafeHtmlCell.render(AbstractSafeHtmlCell.java:80) at com.google.gwt.user.cellview.client.CellList.renderRowValues(CellList.java:527) at com.google.gwt.user.cellview.client.AbstractHasData$View.renderRowValues(AbstractHasData.java:337) at com.google.gwt.user.cellview.client.AbstractHasData$View.replaceAllChildren(AbstractHasData.java:239) at com.google.gwt.user.cellview.client.HasDataPresenter.resolvePendingState(HasDataPresenter.java:1351) at com.google.gwt.user.cellview.client.HasDataPresenter.access$3(HasDataPresenter.java:1062) at com.google.gwt.user.cellview.client.HasDataPresenter$2.execute(HasDataPresenter.java:984) at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50) at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228) at com.google.gwt.core.client.impl.SchedulerImpl.flushFinallyCommands(SchedulerImpl.java:327) at com.google.gwt.core.client.impl.Impl.exit(Impl.java:266) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:257) at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Unknown Source)

I'm not sure why it wants to cast a order to a string. I feel there is something fundamental about serialization I'm missing here, can someone point me in the right direction.

2
Do you have .gwt.xml file @ com/cbs/ioma/ folder? is that included in your jar along with the .java files for com.cbs.ioma.client.Order?appbootup
I have the xml file inside of the WAR file if that is what you are referring to. Do I need a second one? and my order.java is inside com.cbs.ioma.clientjohn

2 Answers

2
votes

Try to implement IsSerializable instead of Serializable. But in general your code should work. This error occurring sometimes (during debug) but in most cases it works after recompile.

1
votes

In order to allow your data types to be transferred from/to client to/from server using GWT-RPC, you need to mark them as serializable by implementing either the IsSerializable or Serializable interface. You also have to ensure the serializability of the class fields (except final/transient fields, which will not be serialized at all) and the presence of a default zero-arg constructor (or none at all).

EDIT: Serialization of final fields is actually under review.

If, for some reason, you cannot meet those requirements, you need to use DTOs filled with your object data, in order to transport them to/from the client/server. Or you can try to implement your own custom serializer for that class.

Take a look at the docs for GWT serialization and to the java.io.Serializable support if you want. And also clean all *.gwt.rpc files in your war dir, to force the re-creaton of the serialization policy.