Hi:

I'm a novice, so apologies if I'm asking this in the wrong place or in the 
wrong manner.  I'm working my way through the book and I'm getting the "Unable 
to block the thread at the cyclic barrier" exception.  Here's what I did:

Step 1. I made a file called MyApplication.java containing this (pages 18-19 of 
the book):

import org.restlet.Application;
import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.Server;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;

public class MyApplication extends Application {

    public static void main(String[] args) throws Exception {
        Server myServer = new Server(Protocol.HTTP, 8111);
        myServer.setNext(new MyApplication());
        myServer.start();
    }

    @Override
    public Restlet createInboundRoot() {
        return new Restlet() {

            @Override
            public void handle(Request request, Response response) {
                String entity = "Method: " + request.getMethod()
                    + "\nResource URI : "
                    + request.getResourceRef()
                    + "\nIP address   : "
                    + request.getClientInfo().getAddress()
                    + "\nAgent name   : "
                    + request.getClientInfo().getAgentName()
                    + "\nAgent        : "
                    + request.getClientInfo().getAgent()
                    + "\nAgent version: "
                    + request.getClientInfo().getAgentVersion();
                response.setEntity(entity, MediaType.TEXT_PLAIN);
            }
        };
    }
}

Step 2. I compiled it with this command:

server$ javac -classpath /tmp/restlet-jse-2.1rc5/lib/org.restlet.jar 
MyApplication.java

Step 3. I ran it with this command:

server$ java -classpath /tmp/restlet-jse-2.1rc5/lib/org.restlet.jar:. 
MyApplication
Starting the internal [HTTP/1.1] server on port 8111

Step 4: From my desktop I sent a request with this command (output included):

client$ curl -i -T text.xml -H "Content-type: application/xml" --header "Host: 
my.server.org:8111" http://my.server.org:8111/foo
HTTP/1.1 200 OK
Date: Mon, 11 Jun 2012 22:07:28 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.1rc5
Content-Length: 255
Content-Type: text/plain; charset=UTF-8

Method: PUT
Resource URI : http://my.server.org:8111/foo
IP address   : 69.60.186.71
Agent name   : null
Agent        : curl/7.24.0 (x86_64-pc-linux-gnu) libcurl/7.24.0 OpenSSL/1.0.0h 
zlib/1.2.6 libidn/1.23 libssh2/1.2.8 librtmp/2.3
Agent version: null
client$


I copied the example right out of the book, only adding the printing of 
request.getClientInfo().getAgent() since getAgentName() and getAgentVersion are 
returning null (because of curl maybe?).  Anyway, except for the null agent 
name and version, the output looks like what's in the book.

Just about 60 seconds later, the server shows the exception in question, and 
only once (in other words, it did not happen again 60 seconds later).  I've 
included the output below.  So, if I'm doing something wrong, I'd be grateful 
to know what.  If this is an actual problem and I should be putting this 
information somewhere else, just let me know and I'll be glad to.  Thanks very 
much.

-Adam

Here's the exception output on the server:

Unable to block the thread at the cyclic barrier

java.util.concurrent.TimeoutException
        at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:222)
        at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:399)
        at 
org.restlet.util.SelectionRegistration.block(SelectionRegistration.java:179)
        at 
org.restlet.engine.io.NbChannelInputStream.onFill(NbChannelInputStream.java:230)
        at org.restlet.engine.io.Buffer.process(Buffer.java:597)
        at 
org.restlet.engine.io.NbChannelInputStream.read(NbChannelInputStream.java:307)
        at java.io.InputStream.read(InputStream.java:85)
        at org.restlet.engine.io.BioUtils.exhaust(BioUtils.java:238)
        at 
org.restlet.representation.Representation.exhaust(Representation.java:247)
        at 
org.restlet.engine.connector.ServerOutboundWay.onCompleted(ServerOutboundWay.java:174)
        at 
org.restlet.engine.connector.HttpServerOutboundWay.onCompleted(HttpServerOutboundWay.java:118)
        at 
org.restlet.engine.connector.OutboundWay.processIoBuffer(OutboundWay.java:416)
        at org.restlet.engine.connector.Way.onSelected(Way.java:430)
        at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:295)
        at 
org.restlet.engine.connector.Connection.onSelected(Connection.java:607)
        at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:295)
        at 
org.restlet.engine.connector.ConnectionController.onSelected(ConnectionController.java:202)
        at 
org.restlet.engine.connector.ServerConnectionController.onSelected(ServerConnectionController.java:99)
        at 
org.restlet.engine.connector.ConnectionController.selectKeys(ConnectionController.java:275)
        at 
org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:155)
        at org.restlet.engine.connector.Controller.run(Controller.java:158)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Unable to automatically exhaust the request entity.

java.io.IOException: Unable to block the thread at the cyclic barrier.
        at 
org.restlet.util.SelectionRegistration.block(SelectionRegistration.java:183)
        at 
org.restlet.engine.io.NbChannelInputStream.onFill(NbChannelInputStream.java:230)
        at org.restlet.engine.io.Buffer.process(Buffer.java:597)
        at 
org.restlet.engine.io.NbChannelInputStream.read(NbChannelInputStream.java:307)
        at java.io.InputStream.read(InputStream.java:85)
        at org.restlet.engine.io.BioUtils.exhaust(BioUtils.java:238)
        at 
org.restlet.representation.Representation.exhaust(Representation.java:247)
        at 
org.restlet.engine.connector.ServerOutboundWay.onCompleted(ServerOutboundWay.java:174)
        at 
org.restlet.engine.connector.HttpServerOutboundWay.onCompleted(HttpServerOutboundWay.java:118)
        at 
org.restlet.engine.connector.OutboundWay.processIoBuffer(OutboundWay.java:416)
        at org.restlet.engine.connector.Way.onSelected(Way.java:430)
        at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:295)
        at 
org.restlet.engine.connector.Connection.onSelected(Connection.java:607)
        at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:295)
        at 
org.restlet.engine.connector.ConnectionController.onSelected(ConnectionController.java:202)
        at 
org.restlet.engine.connector.ServerConnectionController.onSelected(ServerConnectionController.java:99)
        at 
org.restlet.engine.connector.ConnectionController.selectKeys(ConnectionController.java:275)
        at 
org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:155)
        at org.restlet.engine.connector.Controller.run(Controller.java:158)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.util.concurrent.TimeoutException
        at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:222)
        at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:399)
        at 
org.restlet.util.SelectionRegistration.block(SelectionRegistration.java:179)
        ... 24 more

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

Reply via email to