Forums Register Login

Errors from server to client

+Pie Number of slices to send: Send
Hi!
I'm not sure if this question belongs here, but I'll give it try. Here is my RMI application:








Now I need to get those exceptions from server to client. How should I do that?
+Pie Number of slices to send: Send
Passing data requires the data be serialized in both directions. The easiest way is to covert the messages to Strings and pass those to the client.

Next time only include the actual code that matters: http://sscce.org/
+Pie Number of slices to send: Send
Well, question is how:) Everything my server does is called from client. Now it should do something on its own, but it hasn't any reference to client. I was given hint that I can have some class MyErr on server side, which would wrap any exception that occurs there (e.g. MyErr(SQLException)), that would be wrapped in Remote exception RemoteException(MyErr(SQLException)),, that would be sent via RMI to Client and dealt with. But I"m not sure how to accomplish this.
+Pie Number of slices to send: Send
(I would recommend you to brush up your basics by some sun tutorials or some good book)

RemoteException is not meant to throw business exceptions. In most of the cases, RemoteException will be throws when there is a communication problem.

In your case you can define an exception class, may be, MyServerException and add in the throws clause of all your server methods. Whenever, an exception occurs on the server side you will throw this exception.

beda meda wrote: I was given hint that I can have some class MyErr on server side, which would wrap any exception that occurs there (e.g. MyErr(SQLException)), that would be wrapped in Remote exception RemoteException(MyErr(SQLException)),, that would be sent via RMI to Client and dealt with. But I"m not sure how to accomplish this.



Any Exception class will have a constructor that also takes a Throwable. You can wrap any exception into your desired type by using such a constructor.
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1037 times.
Similar Threads
how to call a javabean method from jsp using setproperty
Stub cannot be cast to Interface
performance issue in iterating through large list of result set
Getting value of static variable with Reflection ?
NULL pointer exception.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:57:54.