GWT - Failed to get type signature for class

I am working on a GWT application that searches for files on different servers. I have a search code in a server package in the Search class. To help find local servers, I have a server location in a class called "Login", which is in a common package. The input contains authentication objects that store information for a separate server.

The code for calling Search is as follows:

SearchInterfaceAsync search = GWT.create(SearchInterface.class); AsyncCallback<Void> callback = new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { System.out.println("Error: " + caught.getMessage()); } @Override public void onSuccess (Void results) { System.out.println("Success!"); } }; search.initialize(serverName, login, callback); search.searchServers(search, variousSearchParameters, callback); 

When I run the program and try to search, the program prints Error: could not get type signature for class [Lcom.example.test.shared.Authentication; .

The authentication code is as follows:

 public class Authentication implements Serializable { private static final long serialVersionUID = 5326256122438445301L; private String server; private String userName; private String password; public Authentication(String serverName){ server = serverName; } public Authentication(String serverName, String user, String pass){ server = serverName; userName = user; password = pass; } public String getServer(){ return server; } public String getUserName(){ return userName; } public String getPassword() { return password; } } 

I tried changing the type declaration by adding serialization, switching to IsSerializible, and nothing works!

+6
source share
3 answers

I tried changing the type declaration by adding serialization, switching to IsSerializible, and nothing works!

You missed one: you must have a default constructor (zero-arg), or a new instance cannot be created. The deserialization process creates an object, then assigns the fields.

I believe that you can protect this constructor so that no developer can accidentally use it.

+8
source

In case this helps others, these are the reasons for this error that I have encountered recently. Sending objects from client to server:

  • Missing constructor no-args public MyObject() {}
  • The presence of a member variable defined as Object (an object cannot be serialized)
  • Forget to implement Serializable interface
  • Using Generics where the type is not defined (I think it was <?> Causing problems).
  • Invalid "version" of class "standard" imported. For example, an import List is imported instead of java.util.List.
  • The presence of a member variable of type java.io.Serializable. The member variable can migrate the client server in order, but sending back failed. It turned out that the member was wrapped with a GWT class along a path that was not serializable ("ServerSerializationStreamReader $ BoundedList").
  • The presence of a sub-object (member variable) with one of the above problems.

These errors in GWT may appear as β€œ500 server errors” that are difficult to debug.

Hope this saves you from cutting your hair.

+5
source

My problem was the lack of the IsSerializable flag interface in the class indicated in the error.

0
source

Source: https://habr.com/ru/post/989443/


All Articles