Hi Marcel, Sorry for the delay.... Your are hitting a common misunderstanding with the Servlet integration: the way it is today, you must rematch the full URI ("http://localhost/rootPath/helloworld$" in your router instead of starting from your application's context and matching "/helloworld$". I recommand to attach a HostRouter just before the HelloWorld Restlet, as in the tutorial.
In order to get the context URI, you can use this code: getParameters().get("contextPath"). See also the Javadocs for details: http://www.restlet.org/docs/ext/com/noelios/restlet/ext/servlet/ServerServle t.html In upcoming versions, you will be able to ignore all this plumbing in order to focus on your business logic. Please be patient, beta 18 is coming along :-) Best regards, Jerome > -----Message d'origine----- > De : Marcel Schepers [mailto:[EMAIL PROTECTED] > Envoyé : mardi 15 août 2006 01:13 > À : discuss@restlet.tigris.org > Objet : Re: b17, tomcat and spring > > hello, > > Unfortunately, your suggestion did not work. I've reduced the code in > the hope the problem could be solved. First of all, I removed all the > Spring stuff. The web.xml file only contains the Restlet > stuff. I do not > think the problem is in web.xml. Please continue reading for > my rationale. > > The implementation of the 'org.restlet.target.class' parameter in > web.xml looks like: > > public RestTarget extends RestletContainer implements Serializable > public RestTarget() { > RestletContainerBuilder builder = Builders.buildContainer(this); > RouterBuilder rb = builder.attachRouter(); > rb.attach("/helloworld$", new AbstractRestlet() { > public void handle(Call call) { > call.setOutput(new StringRepresentation("Hello World!", > MediaTypes.TEXT_PLAIN)); > }}); > } > } > > This setup produces a 405 error by Tomcat. > > The thing that puzzles me is that if I comment out all the stuff in > RestTarget's constructor and override the handle method, I see the > expected outcome. In that case RestTarget looks like: > > public class RestTarget extends RestletContainer implements > Serializable { > public RestTarget() { > } > > @Override > public void handle(Call call) { > call.setOutput(new StringRepresentation("Hello World!", > MediaTypes.TEXT_PLAIN)); > } > } > > There must be a brain-shortcut that prevents me from finding the > problem. I have a working restlet container, RestTarget in my > case. I am > only attaching a router to it or am I not? The specified URI > (http://localhost:8080/rest/helloworld) should produce the > 'hello world' > string. > > Greetings, > Marcel > > Jerome Louvel wrote: > > Hi Marcel, > > > > I've had a look at your case. The problem seems to be in > this code snippet: > > for ( ResourceMapping mapping : resourceMappings ) { > > Map<String, Restlet> restletMap = > mapping.getRestletMap(); > > for ( String key : restletMap.keySet() ) { > > LOG.info(key + "/" + restletMap.get(key)); > > builder.attachRouter().attach(key, > restletMap.get(key));}} > > > > You appear to be attaching a root router to your container > multiple times > > which has for effect to erase the previous router set (only > one root Restlet > > allowed). > > > > The solution for you is to store to reference to the > RouterBuilder returned > > by "builder.attachRouter()" then to use it like this: > > RouterBuilder rb = builder.attachRouter(); > > for ( ResourceMapping mapping : resourceMappings ) { > > Map<String, Restlet> restletMap = > mapping.getRestletMap(); > > for ( String key : restletMap.keySet() ) { > > LOG.info(key + "/" + restletMap.get(key)); > > rb.attach(key, restletMap.get(key));}} > > > > I've not tested it, but it should work better. Also, you > might want to check > > this FAQ entry, it contains another example of Spring > integration done by > > A.J. Barnes: > > "Can the Restlets composing a site be defined in an > XML file?" > > http://www.restlet.org/faq#07 > > > > Best regards, > > Jerome > > > >> -----Message d'origine----- > >> De : Marcel Schepers [mailto:[EMAIL PROTECTED] > >> Envoyé : samedi 12 août 2006 13:56 > >> À : discuss@restlet.tigris.org > >> Objet : Re: b17, tomcat and spring > >> > >> Hi Jerome, > >> > >> That would be great. As a counter favor, I'll help you with the > >> Tomcat/Spring integration guide. > >> > >> Have a nice day, > >> Marcel > >> > >> Jerome Louvel wrote: > >>> Hi Marcel, > >>> > >>> Thanks for the details about your issue. There is a plan to > >> write an > >>> integration guide for Tomcat as we are getting many related > >> questions. I'll > >>> have a look at your case and get back to you tomorrow. > >>> > >>> Best regards, > >>> Jerome > >>> > >>>> -----Message d'origine----- > >>>> De : Marcel Schepers [mailto:[EMAIL PROTECTED] > >>>> Envoyé : vendredi 11 août 2006 12:26 > >>>> À : discuss@restlet.tigris.org > >>>> Objet : b17, tomcat and spring > >>>> > >>>> Hello, > >>>> > >>>> I'm having a hard time getting the b17 release running using > >>>> Tomcat and > >>>> Spring. What I am trying to accomplish is the setup as > >> described by > >>>> Manohar Viswanathan, but unlike Manohar I am using the B17 > >> release. > >>>> This is what I've done so far. > >>>> > >>>> The 'standard' stuff in web.xml. The > >>>> 'org.restlet.target.class' is set > >>>> to 'com.javafabric.jobstoday.ws.rest.util.RestTarget', a > >>>> class extending > >>>> 'org.restlet.component.RestletContainer'. The 'handle' > method is > >>>> overridden. For the sake of readability I've attached the > >>>> sources files. > >>>> Looking at RestTarget you'll notice that on the first handle > >>>> invocation > >>>> a manager bean is retrieved from the Spring context. That > >>>> manager uses > >>>> the RestTarget instance to setup a 'RestletContainerBuilder'. > >>>> > >>>> The following snippet shows how I think the various resources > >>>> should be > >>>> linked to instances of Restlet. This snippet is from the > >>>> manager's init > >>>> method. > >>>> > >>>> RestletContainerBuilder builder = > >>>> Builders.buildContainer(rootContainer); > >>>> > >>>> for ( ResourceMapping mapping : resourceMappings ) { > >>>> Map<String, Restlet> restletMap = mapping.getRestletMap(); > >>>> for ( String key : restletMap.keySet() ) { > >>>> LOG.info(key + "/" + restletMap.get(key)); > >>>> builder.attachRouter().attach(key, restletMap.get(key)); > >>>> } > >>>> } > >>>> > >>>> Now, assuming that the key has a value of '/vacancy' and the > >>>> corresponding map class is an instance of Restlet with a > handleGet > >>>> method, then an 'http://localhost:8080/ws-rest/vacancy' > URL should > >>>> invoke the restlet's handleGet method? > >>>> > >>>> I've included the spring configuration file > >>>> (ws-rest-application-context.xml). the resource > (Vacancy.java), an > >>>> overridden RestletContainer (RestTarget.java) and the manager > >>>> to set up > >>>> the restlets and their corresponsind URLs (RestManager.java). > >>>> > >>>> Deployment of this code works like a charm. With the a > >>>> 'http://localhost:8080/ws-rest' url I notice the > invocation of the > >>>> handle method of RestTarget. However, Tomcat gives a 405 > >> error; 'The > >>>> method specified in the Request-Line is not allowed for > >> the resource > >>>> identified by the request URI'. What is it that I do work? > >>>> > >>>> Thank you very much for your time, > >>>> Marcel > >>>> > >>>> > >>>> > >>>> Resources: > >>>> http://manoharviswanathan.com/blog/tech/developing-restful-web > >>>> -services-in-java/ > >>>> > >>>> > >>>> > >>>> > >> > >