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/ 
> >> 
> >> 
> >> 
> >> 
> 
> 

Reply via email to