Marshaling Exceptions Across a Network

JboException can marshal itself across a network. It handles NLS issues for the middle tier, enabling one instance of a middle-tier component to serve (for example) French users and English users at the same time.

If your exception contains member data that must be marshalled, extend JboException. If you need to provide more control over the serialized stream, implement the readObject and writeObject methods. The Java serialization mechanism uses these methods to serialize/deserialize an object. You might want implement these methods if you want to:

For example, suppose you have the class MyException (shown below), and you want to carry memberA and memberB across tiers:

public class MyException extends JboException 
{
int memberA;
String memberB;
...
}

Write code like the following in MyException:

private void writeObject(ObjectOutputStream out) throws IOException { 
out.writeInt(memberA);
out.writeUTF(mEntityRowHandle);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 
memberA = in.readInt();
memberB = in.readUTF();
}