Home : SerializationException when Calling Java Methods that Return a Java Object
Q55264 - ERRMSG: SerializationException when Calling Java Methods that Return a Java Object

SerializationException when Calling Java Methods that Return a Java Object

 

Contents

  1. SYMPTOMS
  2. CAUSE
  3. RESOLUTION

SYMPTOMS

When calling a Java method from a .NET client that returns another Java object, the following exception occurs:

 

CAUSE

The Java object being returned implements the Java interface java.io.Serializable. Because of this, the J-Integra for .NET runtime will automatically try to send a serialized version of the object back to the .NET client. However, the object has not been generated with the "Pass by Value" option using GenNet, and the exception is thrown.

RESOLUTION

There are two different solutions, depending on whether you intended for the returned object to be serializable or not.

To have the method return a serializable object:

  1. Launch GenNet again, and click Next to see the list of classes.
  2. Highlight the object being returned from the method, and click on "Options..."
  3. Click the "Pass by Value" checkbox, and then click OK.
  4. Continue with GenNet to re-generate the C# proxies.
  5. Run your client again and this time it should work as expected.
  6. Keep in mind that Serializable objects only expose public data fields!

 

To have the method return a NON-serializable object:

  1. Launch Janetor again, and highlight the "Local Objects".
  2. Right-click the mouse button and select Add.
  3. Enter the fully qualified name of your Java object that is being returned by the method and then click OK.
  4. Make sure that the "Pass by Reference" checkbox is checked for this class.
  5. For the URI and "Assembly Name" entries, copy/paste the same data from the default node (unless your Java object is located at a different URI or assembly).
  6. Run your client again and this time it should work as expected.
Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.
Created on 6/23/2006.
Last Modified on 7/10/2006.
Last Modified by No Author Name Available!.
Article has been viewed 8220 times.
Rated 3 out of 10 based on 6 votes.
Print Article
Email Article