Thursday, December 19, 2024

Re: Class not included in the set of types for RPC

Enums never need to be marked as serializable - unlike records, the Enum type itself is always serializable, and GWT-RPC assumes the same. From https://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html#DevGuideSerializableTypes

A type is serializable and can be used in a service interface if one of the following is true:
...
 * The type is an enumeration. Enumeration constants are serialized as a name only; none of the field values are serialized.


That error message is indeed what is used when the standard serialization policy is read from disk, so you've resolved that earlier issue. Can you confirm that the policy file does include Line (that is, it is correctly reachable from the remote service instance)? If not, the GWT-RPC generator (run when the compiler is invoked) might not have seen a clear path to how this type could be used. Common reasons for that include declaring a field as being of type Object, which in your head means that any type could be assigned, but GWT-RPC doesn't want to mark every possibly class as potentially serializable (both for security reasons and to avoid generating serialization code for your client for every possible type).

On Thursday, December 19, 2024 at 1:08:53 AM UTC-6 ma...@craig-mitchell.com wrote:
At a guess, the inner enum needs to be told it can be serialised.  Ie:

import com.google.gwt.user.client.rpc.IsSerializable;

enum STATUS implements IsSerializable { ... }

On Thursday, 19 December 2024 at 3:46:31 pm UTC+11 Neil Aggarwal wrote:
I am getting this error on the server:
Type 'com.propfinancing.puzzle.slitherlink.Line' 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 = Line 0

And looking in the .gwt.rpc file, it is not listed there.

Interestingly, I see this:
com.propfinancing.puzzle.slitherlink.Line$STATUS
which is an Enum in that class so the GWT compiler obviously processed the
class.

I did not get any warnings or error messages from the GWT compiler as to
why it
decided it did not like the class so now I have to guess what it did not
like.

Is there a way to improve the messaging to the user to help understand
what happened?

Thank you,
Neil

--
Neil Aggarwal, (972) 834-1565, http://www.propfinancing.com
We offer 30 year loans on single family houses!

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-web-toolkit/ac23c6d8-9df6-4167-ac6a-0e6e4c1b9430n%40googlegroups.com.

No comments:

Post a Comment