Re: Spring + Restlet + Tomcat

2008-03-28 Thread James Horsley

Stephen Mc Namara  gmail.com> writes:

> 
> Hi Rhett 
> 
> thanks for replying. I'll take a look at the links you sent later
> today. 
> 
> In the meantime I've switched back to using the NRE ServerServlet with
> a custom Application that wires in a manager obj to create a Router
> whose config is fed from the applicationContext.xml. The spring config
> uses the SpringFinfer to overload createResource. It all works but I'd
> still like to understand what was wrong with my first approach. If
> anyone has any insights please send them along.
> 
> cheers,
> 
> -s

I'm using a similar Spring + Restlet 1.1 + Tomcat setup and ran into similar
issue of always getting 404. After some debugging I tracked my problem down to
have "/*" as my servlet mapping which was causing
HttpServletRequest.getServletPath() to return "". Restlet was using that result
to determine what the base path was so ended up using the whole path
"http://localhost:1234/blah/56"; when matching against the routes, so of course
"/blah/{id}" isn't going to match.

Not sure if you were having the same issue, but thought I'd post just incase.

Cheers,

James



Re: Spring + Restlet + Tomcat

2008-03-21 Thread Stephen Mc Namara
Hi Rhett 

thanks for replying. I'll take a look at the links you sent later
today. 

In the meantime I've switched back to using the NRE ServerServlet with
a custom Application that wires in a manager obj to create a Router
whose config is fed from the applicationContext.xml. The spring config
uses the SpringFinfer to overload createResource. It all works but I'd
still like to understand what was wrong with my first approach. If
anyone has any insights please send them along.

cheers,

-s
>  Hi Stephen,

>  On Mar 20, 2008, at 10:27 AM, Stephen Mc Namara wrote:
>>   I'm trying without much success to bootstrap a new project using
>> both Spring (2.5) and restlet(1.1-M2). The plan goes something like
>>  this;

>>   *  Restlet resources on the front end which interact with a service
>> layer. The service layer contains some business logic but mostly
>> passes off
>>   calls to a bunch of back end legacy systems. The goal is to expose
>>  those back
>>   end systems as a uniform set of RESTful web services.

>>   *  I want to use Spring primarily for IoC, Aspects and JMX ease of
>> use. Plus being able to fairly easily add thread pools to my back
>> end adapters is appealing; all the usual Spring container arguments.

>>   *  I can't use the Restlet HTTP server and in all likelihood the
>> corporate powers will make us deploy on WebSphere for production but
>>   for now I'm
>>   trying to deploy Spting+Restlet as a WAR inside Tomcat.

>>   I've read all I can find on the restlet site, the faq, the wiki
>> and   this list
>>   about the various integration options but none are working. It
>> seems   there were
>>   some previous integration strategies and some newer options.
>> Various   googling
>>   has produced a confusing list of alternate approaches and I have
>> to   say the
>>   restlet docs need a major boost.

>  This is at least partially my fault.  I promised documentation for
> how  to use RestletFrameworkServlet and SpringBeanRouter/Finder, but
> have  not delivered them yet.
>>   I'd like to use Spring to inject the service layer into my
>> Resources; and in general to use its IoC injection across all the
>> beans. Having restlet config (router config, URL mapping etc)
>> exposed (and   manageable) by
>>   Spring is nice.

>  This is how I use it today.
>>   I'd really appreciate if anyone has a complete end-to-end working
>> example of spring+restlet in tomcat with either approach, or if you
>> can
>>   spot a problem with the config shown above.

>  If you'd like an end-to-end working application of moderate
> complexity, you can look at Patient Study Calendar (PSC):

>  https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/

>  It is the open source clinical research app I developed the
> aforementioned adapter classes for.  It is primarily a Spring-MVC
> webapp, with Spring IoC connecting all the layers.  The RESTful API
> was added after most of the application functionality was in place,
> so  it is somewhat similar to your situation.

>  In particular, I think you'll want to look at


> https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/src/ma
>  in/webapp/WEB-INF/restful-api-servlet.xml

>  which is the spring configuration file for the
> RestletFrameworkServlet  (using SpringBeanRouter) and


> https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/src/ma
>  in/java/edu/northwestern/bioinformatics/studycalendar/restlets/

>  which contains all the Resource implementations.  PSC's not as clean
> as an example written specifically for demonstration, but hopefully
> it  can get the point across for now.

>  Rhett



-- 

I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo




Re: Spring + Restlet + Tomcat

2008-03-20 Thread Rhett Sutphin

Hi Stephen,

On Mar 20, 2008, at 10:27 AM, Stephen Mc Namara wrote:

I'm trying without much success to bootstrap a new project using both
Spring (2.5) and restlet(1.1-M2). The plan goes something like this;


*   Restlet resources on the front end which interact with a service
layer. The service layer contains some business logic but mostly  
passes off
calls to a bunch of back end legacy systems. The goal is to expose  
those back

end systems as a uniform set of RESTful web services.

*   I want to use Spring primarily for IoC, Aspects and JMX ease of
use. Plus being able to fairly easily add thread pools to my back end
adapters is appealing; all the usual Spring container arguments.

*   I can't use the Restlet HTTP server and in all likelihood the
corporate powers will make us deploy on WebSphere for production but  
for now I'm

trying to deploy Spting+Restlet as a WAR inside Tomcat.


I've read all I can find on the restlet site, the faq, the wiki and  
this list
about the various integration options but none are working. It seems  
there were
some previous integration strategies and some newer options. Various  
googling
has produced a confusing list of alternate approaches and I have to  
say the

restlet docs need a major boost.


This is at least partially my fault.  I promised documentation for how  
to use RestletFrameworkServlet and SpringBeanRouter/Finder, but have  
not delivered them yet.



I'd like to use Spring to inject the service layer into my Resources;
and in general to use its IoC injection across all the beans. Having
restlet config (router config, URL mapping etc) exposed (and  
manageable) by

Spring is nice.


This is how I use it today.


I'd really appreciate if anyone has a complete end-to-end working
example of spring+restlet in tomcat with either approach, or if you  
can

spot a problem with the config shown above.


If you'd like an end-to-end working application of moderate  
complexity, you can look at Patient Study Calendar (PSC):


https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/

It is the open source clinical research app I developed the  
aforementioned adapter classes for.  It is primarily a Spring-MVC  
webapp, with Spring IoC connecting all the layers.  The RESTful API  
was added after most of the application functionality was in place, so  
it is somewhat similar to your situation.


In particular, I think you'll want to look at

https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/src/main/webapp/WEB-INF/restful-api-servlet.xml

which is the spring configuration file for the RestletFrameworkServlet  
(using SpringBeanRouter) and


https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/

which contains all the Resource implementations.  PSC's not as clean  
as an example written specifically for demonstration, but hopefully it  
can get the point across for now.


Rhett


Spring + Restlet + Tomcat

2008-03-20 Thread Stephen Mc Namara
I'm trying without much success to bootstrap a new project using both
Spring (2.5) and restlet(1.1-M2). The plan goes something like this;
 

*   Restlet resources on the front end which interact with a service
layer. The service layer contains some business logic but mostly passes off 
calls to a bunch of back end legacy systems. The goal is to expose those back 
end systems as a uniform set of RESTful web services.

*   I want to use Spring primarily for IoC, Aspects and JMX ease of
use. Plus being able to fairly easily add thread pools to my back end
adapters is appealing; all the usual Spring container arguments.

*   I can't use the Restlet HTTP server and in all likelihood the
corporate powers will make us deploy on WebSphere for production but for now 
I'm 
trying to deploy Spting+Restlet as a WAR inside Tomcat.
 

I've read all I can find on the restlet site, the faq, the wiki and this list 
about the various integration options but none are working. It seems there were 
some previous integration strategies and some newer options. Various googling 
has produced a confusing list of alternate approaches and I have to say the 
restlet docs need a major boost. 

I'd like to use Spring to inject the service layer into my Resources;
and in general to use its IoC injection across all the beans. Having
restlet config (router config, URL mapping etc) exposed (and manageable) by 
Spring is nice. 

I've had little success with "Spring as the main container" as all I get is the 
NRE logFilter and a 404 from each of the resource URLs. My
web.xml looks like this;

 

org.restlet.application
application

 

org.restlet.component
component

 


org.springframework.web.context.ContextLoaderListener


 

springRestletServlet
com.noelios.restlet.ext.spring.SpringServerServlet

 

springRestletServlet
/*

 
With an applicationContext.xml that has the named beans "component" and
"application" as follows;









 








 


 



 









 

I also tried the other approach namely "Restlet as the main container"
but that's got it's own errors trying to get the Restlet Application to
load Spring properly and having unwired beans leading to various NPEs.
An earlier example did work but my app resources were 'Restlets' not
'Resources' which didn't feel right either. 

I'd really appreciate if anyone has a complete end-to-end working
example of spring+restlet in tomcat with either approach, or if you can
spot a problem with the config shown above.
 

TIA,

-stephen