Re: Post problems when using Restlet Javascript Edition...

2012-02-15 Thread Richard Berger
Thanks again for your help.  I downloaded tcpmon and made the suggested
changes to my Java client.  I then did a post through Java and below are
the Request and the Response.

Request
POST /commitments/ HTTP/1.1
Date: Wed, 15 Feb 2012 22:19:58 GMT
Content-Length: 109
Content-Type: application/json; charset=UTF-8
Accept: */*
Host: localhost:8880
User-Agent: Restlet-Framework/2.1rc2
Cache-Control: no-cache
Pragma: no-cache
Connection: keep-alive

{"id":0,"title":"Added through post - Java client","description":"This is a
description of post Java client"}

Response...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Wed, 15 Feb 2012 22:19:59 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.1rc2
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Content-Length: 1

4

Then I moved to the Javascript side.  I didn't install Firebug, but instead
I just changed the ClientResource creation from:
  var clientResource = new ClientResource("/commitments/");  /
To:
  var clientResource = new ClientResource("
http://localhost:8880/commitments/";);
where TCPmon was running on 8880 and forwarding to , which is where my
server was listening.

Below are the Request and Response - and they are definitely different than
the Java version...

Request...
OPTIONS /commitments/ HTTP/1.1
Host: localhost:8880
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://localhost:
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML,
like Gecko) Chrome/17.0.963.46 Safari/535.11
Access-Control-Request-Headers: Origin, Content-Type, accept
Accept: */*
Referer: http://localhost:/oldTest.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Response...
HTTP/1.1 200 OK
Content-Type: application/vnd.sun.wadl+xml; charset=UTF-8
Date: Wed, 15 Feb 2012 22:22:22 GMT
Accept-Ranges: bytes
Allow: POST, GET
Server: Restlet-Framework/2.1rc2
Transfer-Encoding: chunked

5D2


http://wadl.dev.java.net/2009/02";>
   
   
  Simple string containing the commitment
ID
   
   
  
 The resource that contains the
list of commitments in the system
 

   
   
   
   
 
 

   
   
   
   

   
   
   
   
   
   
 
  
   


One small typo on the
http://templth.wordpress.com/2011/05/17/activating-tracing-mode-in-restlet/article,
in the ClientResource section the line:
Context context = clientResource.getContext();
should be
context = clientResource.getContext();
(but this is minor - the ease of getting the trace using Restlet tracing
was awesome).

Thanks again for all your assistance!  (And my apologies in advance if the
problem turns out to be some silly mistake in my code - always a real
possibility).

RB


On Wed, Feb 15, 2012 at 6:15 AM, Thierry Templier [via Restlet Discuss] <
ml-node+s1400322n7287572...@n2.nabble.com> wrote:

> Hello Richard,
>
> It could be either an HTTP header not correctly in the JS part or a
> problem on methods signatures within ServerResource class...
>
> Can you give me the request content of both calls from Java and JS?
>
> - For Java, simply active tracing mode on the ClientResource client (
> http://templth.wordpress.com/2011/05/17/activating-tracing-mode-in-restlet/
> ):
>
> String
> url = "(...)";
> Context context = new Context();
> ClientResource clientResource = new ClientResource(context, url);
> Context context = clientResource.getContext();
> context.getParameters().add("tracing", "true");
>
> - For JS, you can have access to the content using for example Firebug...
>
> Thanks!
> Thierry
>
>  First - thank you for your message and the work that you are doing.
>
> I downloaded the latest .js files and the previously reported error is
> indeed fixed.  But my post() is still not being received on the server side
> when called from Javascript.  From Javascript, I am able to succesfully call
> get and put.  From a Java client, I can successfully call post.  And a
> standard HTML form post works too.
>
> Details on the error... (from Chrome's Javascript console)
> POST http://localhost:/commitments/ 415 (Unsupported Media Type)
> Class.lowLevelSendRequestrestlet-browser.js:3681
> Class.sendRequestrestlet-browser.js:3630
> Class.commitrestlet-browser.js:3776
> Class.handlerestlet-browser.js:3812
> Class.handlerestlet-browser.js:3865
> Class.handleNextrestlet-browser.js:4311
> Class.handleRequestrestlet-browser.js:4301
> Class.handlerestlet-browser.js:4293
> Class.postrestlet-browser.js:4232
> (anonymous function)oldTest.html:64
> Test.runqunit.js:102
> Test.queue.badqunit.js:232
> processqunit.js:865
> QUnit.start.config.blocking
>
> Details of my c

Routing problem - Escaped '/' character in URL

2012-02-15 Thread John Wismar
Hey, all-

I'm using Restlet 2.1RC2. I have a search resource that is working fine, except 
we came across a case where the search term has a '/' character in it. 

I'm already expecting the search terms to come in URL encoded, and the request 
that's being sent (to search for "a/b" for example) looks like: /search/a%2Fb

This is not being routed into my code at all, as far as I can tell based on 
debug logging - curl says the server is returning a 400 ("Bad Request"), 
although I don't see it in the server logs.  I have tried modifying the route 
explicitly to support '/' characters, like so:
TemplateRoute searchTemplate = router.attach("/search/{search_terms}", 
SearchResource.class);
searchTemplate.getTemplate().getVariables().put("search_terms", new 
Variable(Variable.TYPE_URI_PATH));

This also is not working with the encoded '/'.  (Also, I didn't think I needed 
to do this anyway, when the '/' character is encoded.)  In fact, in running 
some tests, it turns out that using this code I can get the query routed if 
it's sent as  "/search/a/b".  I don't really want to do this though, because 
there are other characters we're encoding...

As a workaround I'm going to propose that the client app replace '/' characters 
with some other special character. But does anyone have any idea why I'm seeing 
this odd behavior?

Thanks!

--
John Wismar
Alldata Technology
916-478-3296

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

RE: ClientResource Examples?

2012-02-15 Thread guillaume.m...@gmail.com
I've some question about the sample code:

1. How to retrieve the list of customers/users ?
2. What type must I use (ArrayList, Set, List, act...) ?

Because I try to retrieve a list but I got an exception 

java.lang.NoClassDefFoundError: com/sun/syndication/feed/synd/SyndFeed

My code 

Server side



public interface RootControllerResource {
@Get
ArrayList findAll();
}

public class RootController extends ServerResource implements
RootControllerResource {
private ArrayList users;

public RootController() {
super();
// Generate some sample data
this.users = new ArrayList();
users.add(new User(1, "user1", "user_f", "user_l", 26));
users.add(new User(2, "user2", "user_f", "user_l", 24));
}

@Override
public ArrayList findAll() {
return users;
}

}



JEE Client




public class Client {

/**
 * @param args
 */
public static void main(String[] args) {
ClientResource cr = new ClientResource("// uri //");
RootControllerResource rcr = 
cr.wrap(RootControllerResource.class);

ArrayList users = rcr.findAll();

for (User u : users){
System.out.println(u.userid);
System.out.println(u.username);
System.out.println(u.firstname);
System.out.println(u.lastname);
System.out.println(u.age);
}

try {
// Try to get the json representation   
cr.get(MediaType.APPLICATION_JSON).write(System.out);
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}




Say me if it's a good way.

Best regards

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/ClientResource-Examples-tp3506100p7288837.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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

Gwt 2.4 + restlet2.1RC2 return null

2012-02-15 Thread Gabriel Pulido
Hello,

I have a restlet JSE server and a ServerResource that serves a resource: 


  @Get
public ArrayList retrieveObjects() {
   ArrayList test = new ArrayList();
   test.add("item0");
   return test;
}

The server is using the following libraries from the 2.1RC2 restlet J2E package:

com.google.gwt.server.jar
org.codehaus.jackson.core.jar
org.codehaus.jackson.mapper.jar
org.restlet.ext.gwt.jar
org.restlet.ext.jackson.jar
or.restlet.ext.simple.jar
org.restlet.jar
org.simpleframework.jar


On the GWT client side I'm trying to request the serverResource with this code:

ObjectsResourceProxy objectsResource = GWT.create(ObjectsResourceProxy.class);
objectsResource.getClientResource().setReference("http://localhost:8111/v1/environment/objects/";);
  
objectsResource.retrieve(new Result>() {

@Override
public void onSuccess(ArrayList result) {
// TODO Auto-generated method stub


}

@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
   
}
});


When I execute the previous code on the client side of a GWT aplication, the 
server acknowledges the request:
2012-02-15  20:38:18127.0.0.1   -   -   8111GET 
/v1/environment/objects/-   200 -   0   20  
http://localhost:8111   Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0) 
Gecko/20100101 Firefox/10.0
http://127.0.0.1:/Freedomotic_gwt_client.html?gwt.codesvr=127.0.0.1:9997

And it reach the onSucess callback. However the result variable is null always.

In the GWT aplication I have defined the following on the client.gwt.xml

 
  
  
  
  


And I have imported the 
org.restlet.ext.json.jar
org.restlet.ext.xml.jar
org.restlet.ext.gwt.jar
org.restlet.jar
from the restlet 2.1RC2 gwt package.

What I'm missing?

Thank you in advance.
Best regards
Gabriel

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


Re: Restlet + GAE + JAX-RS

2012-02-15 Thread guillaume.m...@gmail.com
Finally it"s ok I misspell the parameter-name (the evil copy/paste) but thank
you for focusing me on these line. 

Thank you very much

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Restlet-GAE-JAX-RS-tp3890645p7288677.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Restlet + GAE + JAX-RS

2012-02-15 Thread guillaume.m...@gmail.com
Same error

I added



org.reslet.application
com.restletexample.JaxRsEntryPoint
 


I think the the parameter "org.reslet.application" expect a class of that
type but my class JaxRsEntryPoint is of type JaxRsApplication

I spend couple of day read the restlet documentation, made all the sample
code they provide but anything works specially on Google AppEngine. 

I commit the code on  https://github.com/guillaumemaka/RestletExample GitHub 

Thank for your help 

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Restlet-GAE-JAX-RS-tp3890645p7288539.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Restlet + GAE + JAX-RS

2012-02-15 Thread Thierry Boileau
Hello Guillaume,

is there any information in the GAE's logs?
To my mind, I think that the servlet called "RestletServlet" is not
properly initiated.
It must have a "org.reslet.application" parameter, with the full path of
your Restlet-based application, in your case, I think it corresponds to the
JaxRsEntryPoint class.

Best regards,
Thierry Boileau


I try the code provide in the
wikibut
it don't work for me, Google App engine say me Error: Not Found !. I
> tried with version (GAE Edition) 2.0.11 and 2.1rc2. My web.xml look like:
> ** ** ** **org.restlet.ext.jaxrs.JaxRsApplication** 
> **com.restletexample.JaxRsEntryPoint
> ** ** ** **RestletServlet** **org.restlet.ext.servlet.ServerServlet** ** *
> * ** ** **RestletServlet** **/*** ** ** **index.html** ** ** and in my
> lib folder I've import those libraries javax.ws.rs.jar javax.xml.bind.jar
> javax.xml.stream.jar org.json.jar org.restlet.ext.jaxrs.jar
> org.restlet.ext.servlet.jar org.restlet.jar My code is available 
> hereIf someone can help 
> me to do it work
> --
> View this message in context: Re: Restlet + GAE + 
> JAX-RS
> Sent from the Restlet Discuss mailing list 
> archiveat Nabble.com.
>

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

Re: Restlet + GAE + JAX-RS

2012-02-15 Thread guillaume.m...@gmail.com
I try the code provide in the 
http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/57-restlet.html?showComments=true#daisycomment151
wiki  but it don't work for me, Google App engine say me Error: Not Found !.
I tried with version (GAE Edition) 2.0.11 and 2.1rc2.

My web.xml look like:





org.restlet.ext.jaxrs.JaxRsApplication

com.restletexample.JaxRsEntryPoint



RestletServlet
org.restlet.ext.servlet.ServerServlet






RestletServlet
/*


index.html



and in my lib folder I've import those libraries 

javax.ws.rs.jar
javax.xml.bind.jar
javax.xml.stream.jar
org.json.jar
org.restlet.ext.jaxrs.jar
org.restlet.ext.servlet.jar
org.restlet.jar

My code is available  http://dl.dropbox.com/u/5552535/RestletExample.zip
here 

If someone can help me to do it work

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Restlet-GAE-JAX-RS-tp3890645p7288376.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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

Re: Post problems when using Restlet Javascript Edition...

2012-02-15 Thread Thierry Templier
Hello Richard,

It could be either an HTTP header not correctly in the JS part or a 
problem on methods signatures within ServerResource class...

Can you give me the request content of both calls from Java and JS?

- For Java, simply active tracing mode on the ClientResource client 
(http://templth.wordpress.com/2011/05/17/activating-tracing-mode-in-restlet/):

String
 
url = "(...)";
Context context = new Context();
ClientResource clientResource = new ClientResource(context, url);
Context context = clientResource.getContext();
context.getParameters().add("tracing", "true");

- For JS, you can have access to the content using for example Firebug...

Thanks!
Thierry

> First - thank you for your message and the work that you are doing.
>
> I downloaded the latest .js files and the previously reported error is
> indeed fixed.  But my post() is still not being received on the server side
> when called from Javascript.  From Javascript, I am able to succesfully call
> get and put.  From a Java client, I can successfully call post.  And a
> standard HTML form post works too.
>
> Details on the error... (from Chrome's Javascript console)
> POST http://localhost:/commitments/ 415 (Unsupported Media Type)
> Class.lowLevelSendRequestrestlet-browser.js:3681
> Class.sendRequestrestlet-browser.js:3630
> Class.commitrestlet-browser.js:3776
> Class.handlerestlet-browser.js:3812
> Class.handlerestlet-browser.js:3865
> Class.handleNextrestlet-browser.js:4311
> Class.handleRequestrestlet-browser.js:4301
> Class.handlerestlet-browser.js:4293
> Class.postrestlet-browser.js:4232
> (anonymous function)oldTest.html:64
> Test.runqunit.js:102
> Test.queue.badqunit.js:232
> processqunit.js:865
> QUnit.start.config.blocking
>
> Details of my client code
> asyncTest("Post with resource Commitment (json)", function() {
>var clientResource = new ClientResource("/commitments/");
>var commitment = {
> title: "From automated test",
> description: "This is from our automated test"
>}
>var jsonRepresentation = new JsonRepresentation(commitment);
>alert(jsonRepresentation.getText());
>// Result is: {"title":"From automated test","description":"This is from
> our automated test"}
>clientResource.post(jsonRepresentation, function(representation) {
>  console.log("representation.getText() = "+representation.getText());
>  // Note: commenting or not commenting out all the lines below doesn't
> make a difference
>  //var jsonRepresentation = new JsonRepresentation(representation);
>  //var obj = jsonRepresentation.getObject();
>  //ok(obj.id, "1");
>  //ok(obj.title, "From automated test");
>  //ok(obj.description, "This is from our automated test");
>  start();
>}, MediaType.APPLICATION_JSON);
> });
>
> You had mentioned that you are still working on the header management
> processing - would that be a likely reason for the 415 error or am I not
> doing something required for Post in particular.
>
> Also, would you still like me to open an issue in GitHub for this problem or
> the previous one?
>
> Thanks so much!
> RB
>
> --
> View this message in context: 
> http://restlet-discuss.1400322.n2.nabble.com/Post-problems-when-using-Restlet-Javascript-Edition-tp7270413p7286087.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2922490

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

Re: Restlet v2.0.4 not working with jetty v7.6.0

2012-02-15 Thread Thierry Boileau
Hello Victoria,

I can only tell you that between two versions of the Jetty library, the API
may change a little bit which should have an impact on the integration made
inside Restlet.
>From what I notice, Restlet 2.0.11 integrates well with Jetty 7.4.5, even
if this release of Restlet has only been tested against and is shipped with
Jetty 7.1.6.

>From time to time, we check new versions of libraries, and we will surely
have a look soon on Jetty 7.6, especially for the 2.1 branch.

Best regards,
Thierry Boileau


Wonder if this is a problem with my project configuration or a problem with
> restlet itself. Recently I tried to upgrade the jetty version from the one
> provided with the restlet installer (v7.1.6) to v7.6.0. My application runs
> fine but I am unable to access it through a browser, it keeps throwing back
> 404 error.
>
> --
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2922871
>

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

Restlet v2.0.4 not working with jetty v7.6.0

2012-02-15 Thread Victoria Chin
Wonder if this is a problem with my project configuration or a problem with 
restlet itself. Recently I tried to upgrade the jetty version from the one 
provided with the restlet installer (v7.1.6) to v7.6.0. My application runs 
fine but I am unable to access it through a browser, it keeps throwing back 404 
error.

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


Re: Restlet server 2.0.11 Threads increase

2012-02-15 Thread Thierry Boileau
Hello Liem,

you can set it as follow : server.setContext(new Context());
Generally, such connector is used inside a Component, which automatically
adjust the connector's context.

Best regards,
Thierry Boileau


My server stops serving after some connections and I would like to increase
> the number of threads.
>
>
> try
> {
>  Server server = new Server(Protocol.HTTP, m_iPort,
> ContentProvider.class);
>  server.start();
> }
> catch (Exception e)
> {
>  e.printStackTrace();
> }
>
> This line below would return a null Context object
> getContext().getParameters().add("maxThreads", "512");
>
> Does anyone have an example or solution?
>
> --
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2922840
>

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

Restlet server 2.0.11 Threads increase

2012-02-15 Thread Liem Truong
My server stops serving after some connections and I would like to increase the 
number of threads.


try
{
  Server server = new Server(Protocol.HTTP, m_iPort, 
 ContentProvider.class);
  server.start();
}
catch (Exception e)
{
  e.printStackTrace();
}

This line below would return a null Context object
getContext().getParameters().add("maxThreads", "512"); 

Does anyone have an example or solution?

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


Re: Post problems when using Restlet Javascript Edition...

2012-02-15 Thread Richard Berger
First - thank you for your message and the work that you are doing.

I downloaded the latest .js files and the previously reported error is
indeed fixed.  But my post() is still not being received on the server side
when called from Javascript.  From Javascript, I am able to succesfully call
get and put.  From a Java client, I can successfully call post.  And a
standard HTML form post works too.

Details on the error... (from Chrome's Javascript console)
POST http://localhost:/commitments/ 415 (Unsupported Media Type)
Class.lowLevelSendRequestrestlet-browser.js:3681
Class.sendRequestrestlet-browser.js:3630
Class.commitrestlet-browser.js:3776
Class.handlerestlet-browser.js:3812
Class.handlerestlet-browser.js:3865
Class.handleNextrestlet-browser.js:4311
Class.handleRequestrestlet-browser.js:4301
Class.handlerestlet-browser.js:4293
Class.postrestlet-browser.js:4232
(anonymous function)oldTest.html:64
Test.runqunit.js:102
Test.queue.badqunit.js:232
processqunit.js:865
QUnit.start.config.blocking

Details of my client code
asyncTest("Post with resource Commitment (json)", function() {
  var clientResource = new ClientResource("/commitments/");
  var commitment = {
   title: "From automated test",
   description: "This is from our automated test"
  }
  var jsonRepresentation = new JsonRepresentation(commitment);
  alert(jsonRepresentation.getText());
  // Result is: {"title":"From automated test","description":"This is from
our automated test"}
  clientResource.post(jsonRepresentation, function(representation) {
console.log("representation.getText() = "+representation.getText());
// Note: commenting or not commenting out all the lines below doesn't
make a difference
//var jsonRepresentation = new JsonRepresentation(representation);
//var obj = jsonRepresentation.getObject();
//ok(obj.id, "1");
//ok(obj.title, "From automated test");
//ok(obj.description, "This is from our automated test");
start();
  }, MediaType.APPLICATION_JSON);
});

You had mentioned that you are still working on the header management
processing - would that be a likely reason for the 415 error or am I not
doing something required for Post in particular.

Also, would you still like me to open an issue in GitHub for this problem or
the previous one?  

Thanks so much!
RB

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Post-problems-when-using-Restlet-Javascript-Edition-tp7270413p7286087.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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