Hi all,
I'm using a ClientResource like this:
TracesService service = ClientResource.create(this.url,
TracesService.class);
where
/**
*
*/
package net.technisys.monitoring.services;
import net.technisys.monitoring.data.restlet.ServerResourceResponse;
import net.technisys.monitoring.data.restlet.TracesPostRequest;
import org.restlet.resource.Get;
import org.restlet.resource.Post;
/**
* @author alejandro
*
*/
public interface TracesService {
@Post("json")
public ServerResourceResponse store(TracesPostRequest request);
@Get("json")
public ServerResourceResponse list();
}
I just use one service instance in a synchronized fashion. Everything works
fine until an error in the communication between client and server occurs,
i.e. server shutdown or even a 404 response.
Then the client sends this kind of exceptions to the log:
07/07/2010 00:22:34 org.restlet.engine.http.connector.Connection
writeMessage
ADVERTENCIA: Exception while writing the message body.
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at
org.restlet.engine.http.io.ChunkedOutputStream.flush(ChunkedOutputStream.java:116)
at
sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at
org.codehaus.jackson.impl.WriterBasedGenerator.close(WriterBasedGenerator.java:712)
at
org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.java:1208)
at
org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1015)
at
org.restlet.ext.jackson.JacksonRepresentation.write(JacksonRepresentation.java:205)
at
org.restlet.representation.WriterRepresentation.write(WriterRepresentation.java:104)
at
org.restlet.engine.http.connector.Connection.writeMessageBody(Connection.java:888)
at
org.restlet.engine.http.connector.Connection.writeMessage(Connection.java:832)
at
org.restlet.engine.http.connector.ClientConnection.writeMessage(ClientConnection.java:297)
at
org.restlet.engine.http.connector.Connection.writeMessages(Connection.java:969)
at
org.restlet.engine.http.connector.Controller$1.run(Controller.java:80)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:595)
07/07/2010 00:22:34 org.restlet.engine.http.connector.ClientConnection
writeMessage
INFO: An exception occured writing the request
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at
org.restlet.engine.http.io.ChunkedOutputStream.flush(ChunkedOutputStream.java:116)
at
sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
...
...
and then, that client doesn't send messages to the server anymore.
Questions:
1) Why does the ClientResource itself handle the exception and output it to
the log instead of throwing an exception so the programmer can handle it and
do whatever it takes? If this is the expected behavior, how can I know when
an exception occurs? is there an error code or something like that?
2) Why does the service instance became unusable? How can I avoid this?
What I want is to always have the same service instance, know when there is
an error when a method is being called on it, and that the instance is
always available, by available I mean working. I'm new to restlet so maybe
I'm missing something.
Thanks in advance.
Alejandro
--
Alejandro Damián Raiczyk
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2630311