Hello,
Sorry for the long post.

The setup, code and exception are below.  Any help in telling me if I should 
configure something differently would be helpful insight to why I am getting 
this exception.  Seems like this should be supported and in fact it does work 
but an exception is thrown a few minutes after the result is returned.

Regards,

Michael Crump

Scenario:

I am running a standalone server behind an secure Apache server working as a 
reverse proxy.

client -> https to apache server (https://external.server.com/foo) -> http to 
restlet server (http://internal/foo)

The pertinent apache config is:

ProxyPass /foo http://internal:8111/foo
ProxyPassReverse /foo http://internal:8111/foo
ProxyPreserveHost On

Simple Restlet Application:

    /**
     * Launches the application with an HTTP server.
     * 
     * @param args
     *            The arguments.
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        Server mailServer = new Server(Protocol.HTTP, 8111);
        mailServer.setNext(new TestServerApplication());
        mailServer.start();
    }

    /**
     * Constructor.
     */
    public TestServerApplication() {
        setName("RESTful Test Server");
        setDescription("Example for showing exception with forwarded request");
        setOwner("Leadscope, Inc.");
        setAuthor("mcrump");
    }

    /**
     * Creates a root Restlet to trace requests.
     */
    @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 version: "
                        + request.getClientInfo().getAgentVersion();
                response.setEntity(entity, MediaType.TEXT_PLAIN);
            }
        };
    }

Execution:

curl https://external.server.com/foo

Output:

Method:  GET
Resource URI:  http://external.server.com/foo
IP address:  192.168.11.xxx
Agent name:  null
Agent version:  null

Exception:

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:176)
    at 
org.restlet.engine.io.NbChannelInputStream.onFill(NbChannelInputStream.java:225)
    at org.restlet.engine.io.Buffer.process(Buffer.java:594)
    at 
org.restlet.engine.io.NbChannelInputStream.read(NbChannelInputStream.java:302)
    at java.io.InputStream.read(InputStream.java:85)
    at org.restlet.engine.io.BioUtils.exhaust(BioUtils.java:235)
    at 
org.restlet.representation.Representation.exhaust(Representation.java:244)
    at 
org.restlet.engine.connector.ServerOutboundWay.onCompleted(ServerOutboundWay.java:171)
    at 
org.restlet.engine.connector.HttpServerOutboundWay.onCompleted(HttpServerOutboundWay.java:114)
    at 
org.restlet.engine.connector.OutboundWay.processIoBuffer(OutboundWay.java:407)
    at org.restlet.engine.connector.Way.onSelected(Way.java:409)
    at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:292)
    at org.restlet.engine.connector.Connection.onSelected(Connection.java:600)
    at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:292)
    at 
org.restlet.engine.connector.ConnectionController.onSelected(ConnectionController.java:197)
    at 
org.restlet.engine.connector.ServerConnectionController.onSelected(ServerConnectionController.java:96)
    at 
org.restlet.engine.connector.ConnectionController.selectKeys(ConnectionController.java:270)
    at 
org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:150)
    at org.restlet.engine.connector.Controller.run(Controller.java:155)
    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:886)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    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:180)
    at 
org.restlet.engine.io.NbChannelInputStream.onFill(NbChannelInputStream.java:225)
    at org.restlet.engine.io.Buffer.process(Buffer.java:594)
    at 
org.restlet.engine.io.NbChannelInputStream.read(NbChannelInputStream.java:302)
    at java.io.InputStream.read(InputStream.java:85)
    at org.restlet.engine.io.BioUtils.exhaust(BioUtils.java:235)
    at 
org.restlet.representation.Representation.exhaust(Representation.java:244)
    at 
org.restlet.engine.connector.ServerOutboundWay.onCompleted(ServerOutboundWay.java:171)
    at 
org.restlet.engine.connector.HttpServerOutboundWay.onCompleted(HttpServerOutboundWay.java:114)
    at 
org.restlet.engine.connector.OutboundWay.processIoBuffer(OutboundWay.java:407)
    at org.restlet.engine.connector.Way.onSelected(Way.java:409)
    at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:292)
    at org.restlet.engine.connector.Connection.onSelected(Connection.java:600)
    at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:292)
    at 
org.restlet.engine.connector.ConnectionController.onSelected(ConnectionController.java:197)
    at 
org.restlet.engine.connector.ServerConnectionController.onSelected(ServerConnectionController.java:96)
    at 
org.restlet.engine.connector.ConnectionController.selectKeys(ConnectionController.java:270)
    at 
org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:150)
    at org.restlet.engine.connector.Controller.run(Controller.java:155)
    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:886)
    at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    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:176)
    ... 24 more

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

Reply via email to