You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nojonojo <n0...@yahoo.com> on 2009/01/20 22:30:40 UTC

restlet usage

I'm possibly interested in working with camel-restlet (2.0, since it doesn't
exist before then).  First off, is there any documentation besides that on 
http://camel.apache.org/restlet.html the restlet component page ?

I'm having two problems.  The first is conceptual - the page that I linked
above really doesn't describe how camel integrates with Restlet, it just
shows a trivial "Hello, world!" level example.  I can probably figure it out
if I can get things working in general, but more documentation there would
be helpful.

Secondly, I can't get a (simpler) "Hello world" sample to work.  At this
point, I'm not interested in the authentication part.  The following is the
class that I'm using:

public class CamelRest extends RouteBuilder
{

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception
	{
		CamelContext context = new DefaultCamelContext();
		context.addRoutes(new CamelRest());
		context.start();
		System.out.println("Server is ready");
		while (true)
		{
			Thread.sleep(10000);
		}
	}

	@Override
	public void configure() throws Exception
	{
		from("restlet:http://localhost:8080/users").process(new Processor()
		{
			public void process(Exchange exchange) throws Exception
			{
				exchange.getOut().setBody("Hello World!");
			}
		});
	}

}

(with appropriate imports).  When I hit http://localhost:8080/users, the
following is the output that I see on my console:

Jan 20, 2009 2:28:49 PM com.noelios.restlet.StatusFilter getStatus
SEVERE: Unhandled exception or error intercepted
java.lang.NoSuchMethodError:
org.restlet.data.Form.getValuesMap()Ljava/util/Map;
	at
org.apache.camel.component.restlet.DefaultRestletBinding.populateExchangeFromRestletRequest(DefaultRestletBinding.java:75)
	at
org.apache.camel.component.restlet.RestletConsumer$1.handle(RestletConsumer.java:53)
	at
org.apache.camel.component.restlet.MethodBasedRouter.handle(MethodBasedRouter.java:55)
	at org.restlet.Filter.doHandle(Filter.java:114)
	at org.restlet.Filter.handle(Filter.java:144)
	at org.restlet.Router.handle(Router.java:454)
	at org.restlet.Filter.doHandle(Filter.java:114)
	at org.restlet.Filter.handle(Filter.java:144)
	at org.restlet.Router.handle(Router.java:454)
	at org.restlet.Filter.doHandle(Filter.java:114)
	at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:98)
	at org.restlet.Filter.handle(Filter.java:144)
	at org.restlet.Filter.doHandle(Filter.java:114)
	at org.restlet.Filter.handle(Filter.java:144)
	at
com.noelios.restlet.component.ComponentHelper.handle(ComponentHelper.java:129)
	at org.restlet.Component.handle(Component.java:240)
	at org.restlet.Server.handle(Server.java:291)
	at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:109)
	at
com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:103)
	at
com.noelios.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:242)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

Being new to Camel, I really don't know where to start.

Thanks.
-- 
View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21572086.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: restlet usage

Posted by William Tam <em...@gmail.com>.
Yea, agreed with lacking documentation on this component.  (I guess
contribution is always welcomed :-))

On the NoSuchMethodError, javadoc says, "Normally, this error is
caught by the compiler; this error can only occur at run time if the
definition of a class has incompatibly changed."   So, are you testing
with restlet 1.1.1?  That's the version camel-restlet was built on.


On Tue, Jan 20, 2009 at 4:30 PM, nojonojo <n0...@yahoo.com> wrote:
>
> I'm possibly interested in working with camel-restlet (2.0, since it doesn't
> exist before then).  First off, is there any documentation besides that on
> http://camel.apache.org/restlet.html the restlet component page ?
>
> I'm having two problems.  The first is conceptual - the page that I linked
> above really doesn't describe how camel integrates with Restlet, it just
> shows a trivial "Hello, world!" level example.  I can probably figure it out
> if I can get things working in general, but more documentation there would
> be helpful.
>
> Secondly, I can't get a (simpler) "Hello world" sample to work.  At this
> point, I'm not interested in the authentication part.  The following is the
> class that I'm using:
>
> public class CamelRest extends RouteBuilder
> {
>
>        /**
>         * @param args
>         * @throws Exception
>         */
>        public static void main(String[] args) throws Exception
>        {
>                CamelContext context = new DefaultCamelContext();
>                context.addRoutes(new CamelRest());
>                context.start();
>                System.out.println("Server is ready");
>                while (true)
>                {
>                        Thread.sleep(10000);
>                }
>        }
>
>        @Override
>        public void configure() throws Exception
>        {
>                from("restlet:http://localhost:8080/users").process(new Processor()
>                {
>                        public void process(Exchange exchange) throws Exception
>                        {
>                                exchange.getOut().setBody("Hello World!");
>                        }
>                });
>        }
>
> }
>
> (with appropriate imports).  When I hit http://localhost:8080/users, the
> following is the output that I see on my console:
>
> Jan 20, 2009 2:28:49 PM com.noelios.restlet.StatusFilter getStatus
> SEVERE: Unhandled exception or error intercepted
> java.lang.NoSuchMethodError:
> org.restlet.data.Form.getValuesMap()Ljava/util/Map;
>        at
> org.apache.camel.component.restlet.DefaultRestletBinding.populateExchangeFromRestletRequest(DefaultRestletBinding.java:75)
>        at
> org.apache.camel.component.restlet.RestletConsumer$1.handle(RestletConsumer.java:53)
>        at
> org.apache.camel.component.restlet.MethodBasedRouter.handle(MethodBasedRouter.java:55)
>        at org.restlet.Filter.doHandle(Filter.java:114)
>        at org.restlet.Filter.handle(Filter.java:144)
>        at org.restlet.Router.handle(Router.java:454)
>        at org.restlet.Filter.doHandle(Filter.java:114)
>        at org.restlet.Filter.handle(Filter.java:144)
>        at org.restlet.Router.handle(Router.java:454)
>        at org.restlet.Filter.doHandle(Filter.java:114)
>        at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:98)
>        at org.restlet.Filter.handle(Filter.java:144)
>        at org.restlet.Filter.doHandle(Filter.java:114)
>        at org.restlet.Filter.handle(Filter.java:144)
>        at
> com.noelios.restlet.component.ComponentHelper.handle(ComponentHelper.java:129)
>        at org.restlet.Component.handle(Component.java:240)
>        at org.restlet.Server.handle(Server.java:291)
>        at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:109)
>        at
> com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:103)
>        at
> com.noelios.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:242)
>        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
>        at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
>        at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
>        at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
>
> Being new to Camel, I really don't know where to start.
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21572086.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: restlet usage

Posted by Claus Ibsen <cl...@gmail.com>.
And remember we love contributions
http://camel.apache.org/contributing.html

So if you get some hands on experience with the component and how to
use it. Then feel free to provide feedback either here in the forum or
signup for edit rights to the wiki pages.

On Wed, Jan 21, 2009 at 4:15 PM, nojonojo <n0...@yahoo.com> wrote:
>
>
> Thanks much - not sure why I didn't notice that.  I had been using restlet
> 1.0.11 instead of 1.1.1.
>
> Understood about the documentation.  It's better to have something working
> with sparse documentation than to have it well documented and not working!
>
>
> P.Budzik wrote:
>>
>>
>> nojonojo wrote:
>>>
>>> I'm possibly interested in working with camel-restlet (2.0, since it
>>> doesn't exist before then).  First off, is there any documentation
>>> besides that on  http://camel.apache.org/restlet.html the restlet
>>> component page ?
>>>
>>> I'm having two problems.  The first is conceptual - the page that I
>>> linked above really doesn't describe how camel integrates with Restlet,
>>> it just shows a trivial "Hello, world!" level example.  I can probably
>>> figure it out if I can get things working in general, but more
>>> documentation there would be helpful.
>>>
>>
>> This component is really fresh stuff delivered recently however I'm glad
>> to see folks being interested in it. You're right, the documentation is
>> sparse. I was going to extend that, but as usual there was no time :) I
>> assure you anyway it works in a real project not only for "hello world".
>> You can count at least on me and William for working out your problem.
>>
>>
>>
>>> Secondly, I can't get a (simpler) "Hello world" sample to work.  At this
>>> point, I'm not interested in the authentication part.  The following is
>>> the class that I'm using:
>>> ....
>>> Being new to Camel, I really don't know where to start.
>>>
>>
>> Seems that you have some dependency problem. Look at the excerpt from my
>> libs:
>>
>>   <classpathentry kind="var"
>> path="M2_REPO/com/noelios/restlet/com.noelios.restlet/1.1.1/com.noelios.restlet-1.1.1.jar"/>
>>   <classpathentry kind="var"
>> path="M2_REPO/com/noelios/restlet/com.noelios.restlet.ext.simple/1.1.1/com.noelios.restlet.ext.simple-1.1.1.jar"/>
>>   <classpathentry kind="var"
>> path="M2_REPO/org/restlet/org.restlet/1.1.1/org.restlet-1.1.1.jar"/>
>>
>> Do your versions match with that? It looks like the binding class is
>> calling Form.getValuesMap() and the one on the classpath has a different
>> signature.
>>
>>
>
> --
> View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21585150.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: restlet usage

Posted by nojonojo <n0...@yahoo.com>.

Thanks much - not sure why I didn't notice that.  I had been using restlet
1.0.11 instead of 1.1.1.

Understood about the documentation.  It's better to have something working
with sparse documentation than to have it well documented and not working!


P.Budzik wrote:
> 
> 
> nojonojo wrote:
>> 
>> I'm possibly interested in working with camel-restlet (2.0, since it
>> doesn't exist before then).  First off, is there any documentation
>> besides that on  http://camel.apache.org/restlet.html the restlet
>> component page ?
>> 
>> I'm having two problems.  The first is conceptual - the page that I
>> linked above really doesn't describe how camel integrates with Restlet,
>> it just shows a trivial "Hello, world!" level example.  I can probably
>> figure it out if I can get things working in general, but more
>> documentation there would be helpful.
>> 
> 
> This component is really fresh stuff delivered recently however I'm glad
> to see folks being interested in it. You're right, the documentation is
> sparse. I was going to extend that, but as usual there was no time :) I
> assure you anyway it works in a real project not only for "hello world".
> You can count at least on me and William for working out your problem. 
> 
> 
> 
>> Secondly, I can't get a (simpler) "Hello world" sample to work.  At this
>> point, I'm not interested in the authentication part.  The following is
>> the class that I'm using:
>> ....
>> Being new to Camel, I really don't know where to start.
>> 
> 
> Seems that you have some dependency problem. Look at the excerpt from my
> libs:
> 
>   <classpathentry kind="var"
> path="M2_REPO/com/noelios/restlet/com.noelios.restlet/1.1.1/com.noelios.restlet-1.1.1.jar"/>
>   <classpathentry kind="var"
> path="M2_REPO/com/noelios/restlet/com.noelios.restlet.ext.simple/1.1.1/com.noelios.restlet.ext.simple-1.1.1.jar"/>
>   <classpathentry kind="var"
> path="M2_REPO/org/restlet/org.restlet/1.1.1/org.restlet-1.1.1.jar"/>
> 
> Do your versions match with that? It looks like the binding class is
> calling Form.getValuesMap() and the one on the classpath has a different
> signature.
> 
> 

-- 
View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21585150.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: restlet usage / process

Posted by Jon Anstey <ja...@gmail.com>.
The latest 2.0-SNAPSHOT should contain the fix since its dated Feb 1

http://people.apache.org/maven-snapshot-repository/org/apache/camel/apache-camel/2.0-SNAPSHOT/apache-camel-2.0-20090201.110840-21.zip

On Mon, Feb 2, 2009 at 3:32 PM, nojonojo <n0...@yahoo.com> wrote:

>
>
> I see that http://issues.apache.org/activemq/browse/CAMEL-1284 was created
> and fixed as a response to this issue.  I have a process question - when
> will the 2.0-SNAPSHOT downloads contain this fix?  (Preferable to compiling
> it myself, though that wouldn't be that big of a deal).
>
> Thanks.
>
> Nolan
>
>
> nojonojo wrote:
> >
> >
> > Okay, next question on usage of the restlet component.
> >
> > I'm trying to POST a new resource via a rest call.  My route looks
> > something like:
> >
> > from("restlet:http://localhost:8080/users/{username}?restletMethod=POST<http://localhost:8080/users/%7Busername%7D?restletMethod=POST>
> ").process(new
> > SetUserProcessor());
> >
> > Where SetUserProcessor might do some processing.
> >
> > I'm POSTing a request with a url like http://localhost:8080/users/homer,
> > and the body is a JSON-encoded String.  I'll worry about processing the
> > JSON later - right now, that's just some payload representing a user.
>  The
> > process method in the processor is being invoked appropriately, and the
> > username header is populated properly in the input.  However, the body of
> > the Message is empty by the time it makes it to the processor.  The data
> > that I have in the body is nowhere to be seen, as far as I can tell.
> >
> > Name-value pairs in the POST body do appear in the headers, it's just
> that
> > when there's a block of data (as you'd do in a POST or a PUT using REST),
> > it doesn't come through.
> >
>
> --
> View this message in context:
> http://www.nabble.com/restlet-usage-tp21572086s22882p21796020.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Jon

http://janstey.blogspot.com/

Re: restlet usage / process

Posted by nojonojo <n0...@yahoo.com>.

I see that http://issues.apache.org/activemq/browse/CAMEL-1284 was created
and fixed as a response to this issue.  I have a process question - when
will the 2.0-SNAPSHOT downloads contain this fix?  (Preferable to compiling
it myself, though that wouldn't be that big of a deal).

Thanks.

Nolan


nojonojo wrote:
> 
> 
> Okay, next question on usage of the restlet component.
> 
> I'm trying to POST a new resource via a rest call.  My route looks
> something like:
> 
> from("restlet:http://localhost:8080/users/{username}?restletMethod=POST").process(new
> SetUserProcessor());
> 
> Where SetUserProcessor might do some processing.
> 
> I'm POSTing a request with a url like http://localhost:8080/users/homer,
> and the body is a JSON-encoded String.  I'll worry about processing the
> JSON later - right now, that's just some payload representing a user.  The
> process method in the processor is being invoked appropriately, and the
> username header is populated properly in the input.  However, the body of
> the Message is empty by the time it makes it to the processor.  The data
> that I have in the body is nowhere to be seen, as far as I can tell.
> 
> Name-value pairs in the POST body do appear in the headers, it's just that
> when there's a block of data (as you'd do in a POST or a PUT using REST),
> it doesn't come through.
> 

-- 
View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21796020.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: restlet usage

Posted by William Tam <em...@gmail.com>.
Hi,

I submitted a fix in the trunk.  Please get it a try.   It hasn't been
merged to the 1.x branch yet.

wtam@lenw500:~/repos/apache/camel/trunk/components/camel-restlet$ svn
ci -m "[CAMEL-1284] Restlet binding does not properly insert/extract
Restlet message."
Sending        camel-restlet/pom.xml
Sending        camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
Deleting       camel-restlet/src/test/java/org/apache/camel/component/restlet/RestRouteBuilderTest.java
Adding         camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletPostContentTest.java
Sending        camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderAuthTest.java
Adding         camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
Transmitting file data .....
Committed revision 736562.


On Wed, Jan 21, 2009 at 4:27 PM, nojonojo <n0...@yahoo.com> wrote:
>
>
> Okay, next question on usage of the restlet component.
>
> I'm trying to POST a new resource via a rest call.  My route looks something
> like:
>
> from("restlet:http://localhost:8080/users/{username}?restletMethod=POST").process(new
> SetUserProcessor());
>
> Where SetUserProcessor might do some processing.
>
> I'm POSTing a request with a url like http://localhost:8080/users/homer, and
> the body is a JSON-encoded String.  I'll worry about processing the JSON
> later - right now, that's just some payload representing a user.  The
> process method in the processor is being invoked appropriately, and the
> username header is populated properly in the input.  However, the body of
> the Message is empty by the time it makes it to the processor.  The data
> that I have in the body is nowhere to be seen, as far as I can tell.
>
> Name-value pairs in the POST body do appear in the headers, it's just that
> when there's a block of data (as you'd do in a POST or a PUT using REST), it
> doesn't come through.
> --
> View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21592556.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: restlet usage

Posted by nojonojo <n0...@yahoo.com>.

Okay, next question on usage of the restlet component.

I'm trying to POST a new resource via a rest call.  My route looks something
like:

from("restlet:http://localhost:8080/users/{username}?restletMethod=POST").process(new
SetUserProcessor());

Where SetUserProcessor might do some processing.

I'm POSTing a request with a url like http://localhost:8080/users/homer, and
the body is a JSON-encoded String.  I'll worry about processing the JSON
later - right now, that's just some payload representing a user.  The
process method in the processor is being invoked appropriately, and the
username header is populated properly in the input.  However, the body of
the Message is empty by the time it makes it to the processor.  The data
that I have in the body is nowhere to be seen, as far as I can tell.

Name-value pairs in the POST body do appear in the headers, it's just that
when there's a block of data (as you'd do in a POST or a PUT using REST), it
doesn't come through.
-- 
View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21592556.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: restlet usage

Posted by "P.Budzik" <pb...@gmail.com>.

nojonojo wrote:
> 
> I'm possibly interested in working with camel-restlet (2.0, since it
> doesn't exist before then).  First off, is there any documentation besides
> that on  http://camel.apache.org/restlet.html the restlet component page ?
> 
> I'm having two problems.  The first is conceptual - the page that I linked
> above really doesn't describe how camel integrates with Restlet, it just
> shows a trivial "Hello, world!" level example.  I can probably figure it
> out if I can get things working in general, but more documentation there
> would be helpful.
> 

This component is really fresh stuff delivered recently however I'm glad to
see folks being interested in it. You're right, the documentation is sparse.
I was going to extend that, but as usual there was no time :) I assure you
anyway it works in a real project not only for "hello world". You can count
at least on me and William for working out your problem. 



> Secondly, I can't get a (simpler) "Hello world" sample to work.  At this
> point, I'm not interested in the authentication part.  The following is
> the class that I'm using:
> ....
> Being new to Camel, I really don't know where to start.
> 

Seems that you have some dependency problem. Look at the excerpt from my
libs:

  <classpathentry kind="var"
path="M2_REPO/com/noelios/restlet/com.noelios.restlet/1.1.1/com.noelios.restlet-1.1.1.jar"/>
  <classpathentry kind="var"
path="M2_REPO/com/noelios/restlet/com.noelios.restlet.ext.simple/1.1.1/com.noelios.restlet.ext.simple-1.1.1.jar"/>
  <classpathentry kind="var"
path="M2_REPO/org/restlet/org.restlet/1.1.1/org.restlet-1.1.1.jar"/>

Do your versions match with that? It looks like the binding class is calling
Form.getValuesMap() and the one on the classpath has a different signature.

-- 
View this message in context: http://www.nabble.com/restlet-usage-tp21572086s22882p21577501.html
Sent from the Camel - Users mailing list archive at Nabble.com.