Re: GWT's Serialization bug: Really unknown error!!!

90 views
Skip to first unread message
Message has been deleted
Message has been deleted

Miguel Méndez

unread,
Aug 21, 2006, 9:50:57 AM8/21/06
to Google-We...@googlegroups.com
Hello Feng,

From your first email, it appears that your client is receiving a packet from the server that contains a type that cannot be deserialized when it is interacting with your myproject.protocol.ILogin service.  What method within the ILogin service are you calling?  What types does it return?

The error message in the dialog box is somewhat of a mystery.  The string "Really unknown error!!!" does not appear anywhere in our source.  Could this be your error message?  Also, we would not normally popup a dialog box when an error is encountered.

Lastly, I put together a dummy service using your ShopGoods and TShopGoods from your second email.  I was able to send that back and forth between the client and the server.  Is there some piece that is missing?

I hope this helps,

On 8/19/06, Feng Jiang <Feng.A...@gmail.com> wrote:

The TShopGoods.java is like:
public class TShopGoods extends ShopGoods {
}

The ShopGoods class is like:
public class ShopGoods implements IsSerializable {

    protected int id = 0;

    protected String shopId = "";

    protected String goodsTitle = "";

    protected int categoryId = 0;

    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("Id=" + id);
        sb.append(",ShopId=" + shopId);
        sb.append(",GoodsTitle=" + goodsTitle);
        sb.append(",CategoryId=" + categoryId);
        return sb.toString();
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getId() {
        return id;
    }

    public void setId(int goodsId) {
        this.id = goodsId;
    }

    public String getGoodsTitle() {
        return goodsTitle;
    }

    public void setGoodsTitle(String goodsTitle) {
        this.goodsTitle = goodsTitle;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

}


can anyone help me ?





--
Miguel
Message has been deleted

Miguel Méndez

unread,
Aug 21, 2006, 11:22:43 AM8/21/06
to Google-We...@googlegroups.com
Hello Feng,

Is TShopGoods defined to be part of the client or server package?  If that class is defined to be part of the client package, the client code will fail to compile.  If that class is defined to be part of the server package and it is being sent back to the client then it would fail to be deserialized on the client.  TShopGoods is not serializable because it references java.sql.ResultSet and java.sql.SQLException which are not serializable nor provided as part of our JRE emulation.  Did you provide your own versions of these classes for use on the client?  If you did a similar trick with the Account class, i.e. have it implement the ITable interface, then it would be susceptible to the same set of issues that TShopGoods encounters.

Lastly, take a look at the code that was displaying the "Really unknown exception!!!".  It was probably catching an exception and then displaying your dialog.  What type of exception was it catching and what was the message in the exception object?

I hope that helps,

On 8/21/06, Feng Jiang <Feng.A...@gmail.com> wrote:

Hi Miguel,

Thanks for your email. What is most instereted is : i checked out a
older version from svn server, which has definately passed the
compiling and basic running(otherwise, I won't commit). and run it
again,  RPC failed. I have used GWT since it was published, and have
been developing app on GWT, no big problem was found until last
weekend. I really don't know what i did.

My comment is in followed:



Miguel Méndez wrote:
> Hello Feng,
>
> From your first email, it appears that your client is receiving a packet
> from the server that contains a type that cannot be deserialized when it is
> interacting with your myproject.protocol.ILogin service.  What method within
> the ILogin service are you calling?  What types does it return?

public interface ILogin extends RemoteService {
    Account login(byte type, String id, String passwd) throws
CheckedException;
}

public abstract class Account implements IsSerializable {
  protected String id = "";
  protected String displayName = "";
  protected String password = "";
  public Account() {}
  public Account(Account account) {
      set(account);
  }
.......//some getter() and setter()
}

And another two classes extend from Account class.

public class Shop extends Account {
    protected String companyName = "";
    protected String brand = "";
...... //some getter() and setter()

}


>
> The error message in the dialog box is somewhat of a mystery.  The string
> "Really unknown error!!!" does not appear anywhere in our source.  Could
> this be your error message?  Also, we would not normally popup a dialog box
> when an error is encountered.

sorry, it is in my code.


>
> Lastly, I put together a dummy service using your ShopGoods and TShopGoods
> from your second email.  I was able to send that back and forth between the
> client and the server.  Is there some piece that is missing?

Yes, I just copy a part of code which i thought is enough.

The TShopGoods should be:

public class TShopGoods extends ShopGoods implements ITable {
    public void read(java.sql.ResultSet rs) throws SQLException {
        id = rs.getInt("Id");
        shopId = rs.getString("ShopId");
        goodsTitle = rs.getString("GoodsTitle");
        categoryId = rs.getInt("CategoryId");

    }
}

public class ShopGoods implements IsSerializable {
    protected int id = 0;
    protected String shopId = "";
    protected String goodsTitle = "";
    protected int categoryId = 0;
......//some getter() and setter()
}

public interface ITable {
    void read(java.sql.ResultSet rs) throws SQLException;
> ------=_Part_30679_10701683.1156168257316
> Content-Type: text/html; charset=ISO-8859-1
> X-Google-AttachSize: 3742
>
> Hello Feng,<br><br>From your first email, it appears that your client is receiving a packet from the server that contains a type that cannot be deserialized when it is interacting with your myproject.protocol.ILogin service.&nbsp; What method within the ILogin service are you calling?&nbsp; What types does it return?
> <br><br><div style="direction: ltr;"></div>The error message in the dialog box is somewhat of a mystery.&nbsp; The string &quot;Really unknown error!!!&quot; does not appear anywhere in our source.&nbsp; Could this be your error message?&nbsp; Also, we would not normally popup a dialog box when an error is encountered.
> <br><br>Lastly, I put together a dummy service using your ShopGoods and TShopGoods from your second email.&nbsp; I was able to send that back and forth between the client and the server.&nbsp; Is there some piece that is missing?<br>
> <br>I hope this helps,<br><br><div><span class="gmail_quote">On 8/19/06, <b class="gmail_sendername">Feng Jiang</b> &lt;<a href="mailto: Feng.A...@gmail.com">Feng.A...@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> <br>The TShopGoods.java is like:<br>public class TShopGoods extends ShopGoods {<br>}<br><br>The ShopGoods class is like:<br>public class ShopGoods implements IsSerializable {<br><br>&nbsp;&nbsp;&nbsp;&nbsp;protected int id = 0;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;protected String shopId = &quot;&quot;;
> <br><br>&nbsp;&nbsp;&nbsp;&nbsp;protected String goodsTitle = &quot;&quot;;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;protected int categoryId = 0;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public String toString() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StringBuffer sb = new StringBuffer();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sb.append(&quot;Id=&quot; + id);
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sb.append(&quot;,ShopId=&quot; + shopId);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sb.append(&quot;,GoodsTitle=&quot; + goodsTitle);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sb.append(&quot;,CategoryId=&quot; + categoryId);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return sb.toString();<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>
> <br>&nbsp;&nbsp;&nbsp;&nbsp;public int getCategoryId() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return categoryId;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public void setCategoryId(int categoryId) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.categoryId = categoryId;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public int getId() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return id;
> <br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public void setId(int goodsId) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=" http://this.id">this.id</a> = goodsId;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public String getGoodsTitle() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return goodsTitle;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public void setGoodsTitle(String goodsTitle) {
> <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.goodsTitle = goodsTitle;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public String getShopId() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return shopId;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public void setShopId(String shopId) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.shopId = shopId;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>
> }<br><br><br>can anyone help me ?<br><br><br></blockquote></div><br><br clear="all"><br>-- <br>Miguel
>
> ------=_Part_30679_10701683.1156168257316--





--
Miguel
Message has been deleted

Miguel Méndez

unread,
Aug 23, 2006, 3:54:25 PM8/23/06
to Google-We...@googlegroups.com
Hey Feng,

I think that everything is clear now.  I dug back into the stack trace of your original email and infact the SerializationException that you are seeing is due to a TShopGoods instance being sent back to the client from the server.  Specifically, an instance of " myproject.server.db.table.TShopGoods". 

For the reasons that I stated in my previous email, the client will be unable to deserialize an instance of a TShopGoods.  If you want the client to be able to deserialize an instance of TShopGoods, then it or some variant of it, needs to be in the client package.  Only classes in the client package are compiled into JavaScript.

I hope that helps,

On 8/22/06, Feng Jiang <Feng.A...@gmail.com> wrote:

Hi Miguel,

TShopGoods is not in the client package, otherwise the source code
cannot be compiled. The TShopGoods is located in server package, and
SQLException is definately caught in the server side if it happens
(actually any exception is caught before returned back to client site).
Based on the developer guider, i can do everything in the server side.

The implementation of ILogin interface is like:
public Account login(byte type, String id, String passwd) throws
CheckedException {
        if (type == Constant.SHOP)
            return loginAsShop(id, passwd); //it successfully returned
a instance of a subclass of Account
        else if (type == Constant.PERSON)
            return loginAsPerson(id, passwd);
        else
            throw new CheckedException("Unknown login type.");
}


I debug the host-mode(not web mode) in eclipse, and the ILoginImpl
successfully returns an Account instance. but client side got a
SerializationException as my frist email.

In one word, the server side returned a correct instance, and client
got a Exception.

Thanks alot,

Feng





--
Miguel

Miguel Méndez

unread,
Apr 4, 2007, 3:43:08 PM4/4/07
to Tiago Night, Google-We...@googlegroups.com
[+Google-Web-T...@googlegroups.com]

Based on the information that you have given, it does seem possible.  The link I provided and the examples should provide a good description of how to make the class serializable with regards to GWT.

What is the return type of your service method?  What did you make your Bean class implement IsSerializable?

On 4/4/07, Tiago Night < tiago...@gmail.com> wrote:
first thanks for the very quick answer!!!

I tried to make Bean Serialize but it got me an other error

i wanna know if what i wanna to do is possible!! Is there an other way to solve the issue 23?

"Probably the class is not considered serializable "
is there a way to make it considered?

thankz again

Regards
Tiago

2007/4/4, Miguel Méndez < mme...@google.com>:
Hi Tiago,

It seems like this would be related to issue 23.  Probably the class is not considered serializable and so client side code throws and runs into issue 23. 

Did you add the @gwt.typeArgs javadoc annotation to service method's return type?  Check out the following link for how to do this: http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.SerializableTypes.html

Let me know if you are still having problems.

On 4/4/07, JavaNight <tiago...@gmail.com> wrote:
Hello
My name is Tiago, Im from Brasil!!

I just started to use GWT, and by the way, did amazing things with
less effort. The most greatfull thing i found about it..was the
numbers of errors that it got, till now it was ZERO! But now i had
this Javascript error..then i realized that it could be my class.. and
reading your post i saw that maybe its the problem. Let me explain.

1 - I have a very simple class(bean), and it is in myproject.client
package.

2- In my Service class method, i return a Collection of this
Class(bean). And the error occurs in my CLIENT.

3- When i change the return of my service method to return a
Collection of String class instead of the Bean class, it works just
fine!!!!!!!!

ERROR: java.lang.RuntimeException: Checked exception thrown into
JavaScript
(web mode behavior may differ)

I wanna know.. cant i return my client class from the server?? or
maybe im doing something wrong!!!
Sorry for bother, and thanks in advice!!!

Tiago



--
Miguel




--
Miguel

Miguel Méndez

unread,
Apr 5, 2007, 9:52:41 AM4/5/07
to Tiago Night, Google-We...@googlegroups.com
[+Google-Web-T...@googlegroups.com]

Not a problem at all.  Enjoy!

On 4/5/07, Tiago Night <tiago...@gmail.com> wrote:
Hello
i followed the link you send me and it work
i missed the link in your first reply, i was very busy here..sorry!! but today i read and made my class implements IsSerializable... it worked
thankz for your attention, for your fast reply and for the very good work you are doing with GWT!!



--
Miguel
Reply all
Reply to author
Forward
0 new messages