How to tell which client connector library is being used

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to tell which client connector library is being used

Robert Dodier
Hello,

I am using Restlet as a client (and also as a server, but I am not
having problems with that). I ran into a problem in which Restlet
would start throwing Exceptions after running for a few days --
"too many open files" at first, for a while, then after a while,
UnknownHostException. Dunno what's going on there.

Anyway I tried to replace the default client connector
with the connector based on Apache HttpClient.
From what I can tell, if I put the Apache HttpClient jars
in the classpath, it will be used automatically.
Is that right? How can I tell which client connector is
being used? I don't see any kind of log output which tells
the client connector class.

I've appended the first "too many open files" exception;
many more are thrown after that. I don't see any org.apache
classes in the stack trace -- should I expect to see some
if the Apache HttpClient is in use?

Thanks for any light you can shed on this problem.

Robert Dodier

PS. Here are the jars relevant to Restlet in the classpath:

org.json.jar
org.restlet.ext.json.jar
org.restlet.jar
org.eclipse.jetty.server.jar
org.eclipse.jetty.io.jar
org.eclipse.jetty.continuation.jar
org.eclipse.jetty.http.jar
org.eclipse.jetty.ajp.jar
org.eclipse.jetty.util.jar
org.restlet.ext.jetty.jar
org.apache.httpclient.jar
org.apache.commons.logging.jar
org.apache.commons.codec.jar
javax.servlet.jar

PPS.
Communication Error (1001) - The connector failed to complete the
communication with the server
    at org.restlet.resource.ClientResource.doError(ClientResource.java:612)
    at org.restlet.resource.ClientResource.handleInbound(ClientResource.java:1202)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1026)
    at org.restlet.resource.ClientResource.post(ClientResource.java:1418)
[snip my code which is kicked off by a timer and calls Restlet]
    at java.util.TimerThread.mainLoop(Timer.java:534)
    at java.util.TimerThread.run(Timer.java:484)
Caused by: java.net.SocketException: Too many open files
    at sun.nio.ch.Net.socket0(Native Method)
    at sun.nio.ch.Net.socket(Net.java:115)
    at sun.nio.ch.SocketChannelImpl.<init>(SocketChannelImpl.java:102)
    at sun.nio.ch.SelectorProviderImpl.openSocketChannel(SelectorProviderImpl.java:55)
    at java.nio.channels.SocketChannel.open(SocketChannel.java:122)
    at org.restlet.engine.connector.ClientConnectionHelper.createSocketChannel(ClientConnectionHelper.java:128)
    at org.restlet.engine.connector.ClientConnectionHelper.getBestConnection(ClientConnectionHelper.java:316)
    at org.restlet.engine.connector.ClientConnectionHelper.doHandleOutbound(ClientConnectionHelper.java:194)
    at org.restlet.engine.connector.BaseHelper.handleOutbound(BaseHelper.java:627)
    at org.restlet.engine.connector.ClientConnectionHelper.handleOutbound(ClientConnectionHelper.java:466)
    at org.restlet.engine.connector.BaseHelper.control(BaseHelper.java:240)
    at org.restlet.engine.connector.Controller.doRun(Controller.java:88)
    at org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:162)
    at org.restlet.engine.connector.Controller.run(Controller.java:159)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3056810
Reply | Threaded
Open this post in threaded view
|

RE: How to tell which client connector library is being used

Jerome Louvel-3
Hi Robert,

It seems that you are missing the org.restlet.ext.httpclient.jar in the classpath which will actually support the Apache HTTP client library.

Best regards,
Jerome
--
http://restlet.org
http://twitter.com/#!/jlouvel

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3057408
Reply | Threaded
Open this post in threaded view
|

RE: How to tell which client connector library is being used

Robert Dodier
> It seems that you are missing the
> org.restlet.ext.httpclient.jar in the classpath which
> will actually support the Apache HTTP client library.

Thanks for the tip. I've updated the classpath.
I realize now that I didn't pay attention to the
lib/readme.txt which has the list of jars for
the Apache Httpclient extension.

Incidentally lib/readme.txt doesn't mention that
the SSL library is needed by the Httpclient extension.
I found out by getting a ClassNotFoundException
for SslUtils (used by HttpClientHelper). I suppose
that's a bug.

I have to say this business of changing the
connectors based on what's in the classpath is
really a disaster. Surely it would be better to
name the connector class somewhere.

best

Robert Dodier

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3057410
Reply | Threaded
Open this post in threaded view
|

Re: How to tell which client connector library is being used

Jerome Louvel-3
Hi Robert,

I agree with the issue regarding classpath magic.

We'll make this explicit at the Restlet API level in v3.0 for connectors & convertors.

Thanks,
Jerome


On Mon, Jun 10, 2013 at 12:56 PM, Robert Dodier <[hidden email]> wrote:
> It seems that you are missing the
> org.restlet.ext.httpclient.jar in the classpath which
> will actually support the Apache HTTP client library.

Thanks for the tip. I've updated the classpath.
I realize now that I didn't pay attention to the
lib/readme.txt which has the list of jars for
the Apache Httpclient extension.

Incidentally lib/readme.txt doesn't mention that
the SSL library is needed by the Httpclient extension.
I found out by getting a ClassNotFoundException
for SslUtils (used by HttpClientHelper). I suppose
that's a bug.

I have to say this business of changing the
connectors based on what's in the classpath is
really a disaster. Surely it would be better to
name the connector class somewhere.

best

Robert Dodier

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