Hi,

I'm a fascinated user of your framework (version 2.08). This is why I'm 
currently trying to use Restlet in an OSGi environment for the practical part 
of my thesis. Finally, I arrived to create a server bundle (which is started by 
the Activator in my Felix OSGi environment) and to show a message as a response 
to a simple call like "http://localhost:8888/";.

But I don't succeed to call another resource from my Restlet. Imagine the case 
that I need data from "http://localhost:8080/tripleStore/triples/5"; in order to 
calculate the result of "http://localhost:8888/test";. (code snippet follows...)

public void startServer() throws Exception {
   component = new Component();
   Server server = new Server ( Protocol.HTTP, 8888);
   component.getServers().add(server);
   Client client = new Client (Protocol.HTTP);
   component.getClients().add(client);

   Restlet restlet = new Restlet() {  
      @Override  
      public void handle(Request request, Response response)  {
         response.setEntity("Container Resource is active!", 
MediaType.TEXT_PLAIN);  
      }  
   }; 
                        
   Restlet restletTest = new Restlet() {
      @Override  
      public void handle(Request request, Response response)  {
         RdfClientResource cli = new 
RdfClientResource("http://localhost:8080/tripleStore/triples/5";);
         cli.setFollowingRedirects(false);
         Representation repri = cli.get();
         response.setEntity(repri);
      }  
   }; 
                        
   component.getDefaultHost().attach("/container",new Sink());
   component.getDefaultHost().attach("/test",restletTest);
   component.getDefaultHost().attach(restlet);
   component.getClients().add(Protocol.HTTP);
   component.start();
}

Currently I'm getting a "bad request"-error when I call
"http://localhost:8080/tripleStore/triples/5"; in my restlet and a 
"forbidden"-error when I call "http://127.0.0.1:8080/tripleStore/triples/5"; 
from my Restlet.

Further research has shown that the cause for this errors is quite simple. The 
restlet tries to get it's results directly from the network proxy, which 
doesn't know any "localhost" and forbids the call to "127.0.0.1".

Another critical point is, that the error was always replicable, except during 
one try. In this case, everything worked fine. This is why I assume a relation 
to the OSGi startup order. (Which isn't fix and depends on the Sonatype 
Aether-framework.)

Are you already aware of an error like this? And can you suggest me any bugfix 
avoiding to try all OSGi startup orders by hand? When I try to do these things 
outside of OSGi, everything works quite fine.

Thanks in advance!
Marcus

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

Reply via email to