Re: [Restlet Android] Object representation selection (application/x-java-serialized-object vs. application/json)

2012-04-25 Thread Tim Peierls
Another way to do it is to replace the built-in converter with my custom
converter. See this message:

http://restlet.tigris.org/ds/viewMessage.do?dsMessageId=2716118&dsForumId=4447

There has been some activity regarding scoring. Here's a recent issue
(which points back to an original older issue):

https://github.com/restlet/restlet-framework-java/issues/255

There have also been some bug fixes regarding scoring, but I don't have
pointers to those.

--tim

On Wed, Apr 25, 2012 at 8:06 PM, Richard Berger wrote:

> Engine.getInstance().getRegisteredConverters().add(0, new
> JacksonConverter());
>
> Worked for me - putting the JacksonConverter first seemed to restore the
> "automagic" :)
> RB
>
> --
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952958
>

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952960

RE: [Restlet Android] Object representation selection (application/x-java-serialized-object vs. application/json)

2012-04-25 Thread Richard Berger
Engine.getInstance().getRegisteredConverters().add(0, new JacksonConverter());

Worked for me - putting the JacksonConverter first seemed to restore the 
"automagic" :)
RB

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952958


RE: [Restlet Android] Object representation selection (application/x-java-serialized-object vs. application/json)

2012-04-25 Thread Richard Berger
Sorry for resurrecting this old thread, but I was wondering if you found a 
better solution than:
Engine.getInstance().getRegisteredConverters().clear();

My post(someObj) were working fine - being handled by the @Post("json") method 
in the interface (using Restlet 2.2 GAE edition on the server, Restlet 2.2 
Android on the client).  

Then for Android reasons I had to change SomeObj to implement Serializable.  
This seemed to change the media type to application/x-java-serialized-object 
which caused my post(someObj) to return a 415 error.

Clearing the converters fixed the problem, but I was just curious if you found 
a better solution.

Thanks!
RB

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952955


Re: No buffer space available (maximum connections reached?)

2012-04-25 Thread Arjohn Kampman
Hi all, me again :-)

I have debugged this issue further and have probably found a simple fix. 
I've migrated from 2.0.x to 2.1.x in the mean time and both version are 
affected by this issue.

The "Unable to establish loopback connection" problem surfaces when 
using resources that return WritableRepresentation objects. In the stack 
trace below, ChannelRepresentation.write(OutputStream) converts the 
writable channel to a readable one through 
WritableRepresentation.getChannel() and 
NioUtils.getReadableByteChannel(...). This last method uses a 
java.nio.channels.Pipe as a buffer between the writer and reader. 
Because this pipe isn't closed/released in time, the system will run out 
of available ports under high load, resulting in the shown stack trace.

Making sure that the reader-side of the pipe is always closed could help 
to resolve this issue, but there's a more elegant solution that doesn't 
use ports. This solution is to override write(OutputStream) in 
WritableRepresentation, wrap the OutputStream in a WritableByteChannel 
using e.g. java.nio.channels.Channels.newChannel(...) and pass that to 
WritableRepresentation.write(WritableByteChannel). Gut feeling is that 
this might even improve the performance as it feels like a lighter 
weight approach than using the system's pipes.

WDYT? Can we get this fix?

Cheers,

Arjohn



On 20/04/2012 10:01, Arjohn Kampman wrote:
> Hi all,
>
> My restlet server is running into the error mentioned in the subject
> after a couple of minutes of moderate load. After this error, the server
> stops responding. Does anyone know what causes this error and how it can
> be fixed?
>
> The full stack trace looks like this:
>
> org.restlet.engine.http.adapter.ServerAdapter commit
> SEVERE: An exception occured writing the response entity
> java.io.IOException: Unable to establish loopback connection
>   at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:106)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at sun.nio.ch.PipeImpl.(PipeImpl.java:122)
>   at 
> sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:27)
>   at java.nio.channels.Pipe.open(Pipe.java:133)
>   at org.restlet.engine.io.NioUtils.getChannel(NioUtils.java:160)
>   at
> org.restlet.representation.WritableRepresentation.getChannel(WritableRepresentation.java:65)
>   at
> org.restlet.representation.ChannelRepresentation.write(ChannelRepresentation.java:71)
>   at
> org.restlet.engine.application.EncodeRepresentation.write(EncodeRepresentation.java:304)
>   at
> org.restlet.engine.http.ServerCall.writeResponseBody(ServerCall.java:550)
>   at org.restlet.engine.http.ServerCall.sendResponse(ServerCall.java:488)
>   at
> org.restlet.ext.jetty.internal.JettyCall.sendResponse(JettyCall.java:327)
>   at
> org.restlet.engine.http.adapter.ServerAdapter.commit(ServerAdapter.java:197)
>   at
> org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:151)
>   at
> org.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:167)
>   at
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594)
>   at
> org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1042)
>   at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:549)
>   at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:211)
>   at 
> org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424)
>   at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506)
>   at
> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
>   at java.lang.Thread.run(Thread.java:662)
> Caused by: java.net.SocketException: No buffer space available (maximum
> connections reached?): connect
>   at sun.nio.ch.Net.connect(Native Method)
>   at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:500)
>   at java.nio.channels.SocketChannel.open(SocketChannel.java:146)
>   at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:78)
>
>
> Any help would be highly appreciated. Thanks in advance!
>

-- 
Arjohn Kampman - www.aduna-software.com

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2952569