Hello Hendrik,

from what I notice, the JaxRs extension does not isolate correctly the
handling of client calls inside a JaxRsRestlet. The thread that handles the
incoming request is disturbed when a new client request is issued. I don't
see clearly the solution right now. There is already an issue for that (
https://github.com/restlet/restlet-framework-java/issues/374).


Best regards,
Thierry Boileau


Thanks for your reply.
>
> Unfortunately your example throws an exception in my application.
> My (simplified) application looks like this:
>
>
> package test;
>
> import java.util.HashSet;
> import java.util.Set;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.Application;
>
> import org.restlet.Component;
> import org.restlet.data.Protocol;
> import org.restlet.ext.jaxrs.JaxRsApplication;
> import org.restlet.representation.Representation;
> import org.restlet.resource.ClientResource;
>
> public class TestServer {
>
>     public static void main(String[] args) throws Exception {
>         Component component = new Component();
>         component.getServers().add(Protocol.HTTP);
>         component.getClients().add(Protocol.HTTP);
>         JaxRsApplication jaxRsApplication = new
> JaxRsApplication(component.getContext().createChildContext());
>         jaxRsApplication.add(new Application() {
>             @Override
>             public Set<Class<?>> getClasses() {
>                 Set<Class<?>> set=new HashSet<Class<?>>();
>                 set.add(TestJaxRsRestlet.class);
>                 return set;
>             }
>         });
>         component.getDefaultHost().attach(jaxRsApplication);
>         component.start();
>
>     }
>
>     @Path("test")
>     public static class TestJaxRsRestlet{
>         @GET
>         @Path("direct")
>         @Produces("text/plain")
>         public String getSomeText() {
>             return "OK";
>         }
>
>         @GET
>         @Path("indirect")
>         @Produces("text/plain")
>         public String readFromUri() {
>             ClientResource res=new
> ClientResource("http://127.0.0.1/test/direct";);
>             Representation rep=res.get();
>             return rep.toString();
>         }
>     }
>
> }
>
> Doing a GET on http://127.0.0.1/test/direct in a browser works and
> returns the string "OK".
> But GETing http://127.0.0.1/test/indirect throws the following exception:
>
> 10.04.2012 17:38:31 org.restlet.engine.log.LogFilter afterHandle
> INFO: 2012-04-10 17:38:31    127.0.0.1    -    -    80    GET
> /test/direct    -    200    2    0    18    http://127.0.0.1
> Restlet-Framework/2.0.11    -
> 10.04.2012 17:38:31 org.restlet.engine.application.StatusFilter doHandle
> WARNUNG: Exception or error caught in status service
> java.lang.IllegalStateException: No CallContext given until now
>     at
>
> org.restlet.ext.jaxrs.internal.core.ThreadLocalizedContext.get(ThreadLocalizedContext.java:123)
>     at
> org.restlet.ext.jaxrs.JaxRsRestlet.handleResult(JaxRsRestlet.java:780)
>     at org.restlet.ext.jaxrs.JaxRsRestlet.handle(JaxRsRestlet.java:726)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at
> org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
>     at
>
> org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
>     at org.restlet.Application.handle(Application.java:388)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.routing.Router.doHandle(Router.java:497)
>     at org.restlet.routing.Router.handle(Router.java:737)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.routing.Router.doHandle(Router.java:497)
>     at org.restlet.routing.Router.handle(Router.java:737)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at
> org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.routing.Filter.doHandle(Filter.java:156)
>     at org.restlet.routing.Filter.handle(Filter.java:203)
>     at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
>     at org.restlet.Component.handle(Component.java:388)
>     at org.restlet.Server.handle(Server.java:488)
>     at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71)
>     at
> org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:150)
>     at
>
> org.restlet.ext.simple.internal.SimpleContainer.handle(SimpleContainer.java:77)
>     at
> org.simpleframework.http.core.Dispatcher.dispatch(Dispatcher.java:107)
>     at org.simpleframework.http.core.Dispatcher.run(Dispatcher.java:90)
>     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)
> 10.04.2012 17:38:31 org.restlet.engine.log.LogFilter afterHandle
> INFO: 2012-04-10 17:38:31    192.168.255.106    -    -    80
> GET    /test/indirect    -    500 423 0 336
> http://192.168.0.4    Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1)
> Gecko/20100101 Firefox/7.0.1 Iceweasel/7.0.1    -
>
> Did I missed something here?
>
>
> On 06.04.2012 14:57, Thierry Boileau wrote:
> > new ClientResource("http://192.168.0.1/foo";).get().write(System.out);
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2946899
>

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

Reply via email to