restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
649 stars 285 forks source link

java.lang.StackOverflowError when using SpringServerServlet #685

Open massyl opened 11 years ago

massyl commented 11 years ago

Hi, I'm facing one problem when configuring RestletComponent with relative path using spring in apache camel. i configured SpringServerServlet and RestletComponent as documented on camel site. when i try to reach my endpoint i get java.lang.StackOverflowError (at org.restlet.ext.servlet.internal.ServletWarEntity.(ServletWarEntity.java:111))

when i run my application in debug mode i see that ServerServlet adds an entry createWarClient(Context context, ServletConfig config) that causes a deap recursion for looking resouce (restlet.xml). in ServerServlet (that SpringServerServlet extends), there is a method init(Component) that adds an entry to deal with war protocol and then causes deap recusion to find resources (restlet.xml). The java doc of ServerServlet states that there is 3 modes of configuration and when we use second option (2) then : The "/WEB-INF/web.xml" file contains a parameter named "org.restlet.component" that gives the class of the component to use. with SpringServerServlet this component is looked up from the applciaitonContext and this is true and the component is found. but after this look up there is a call to init(Component) inside ServerServlet that causes a search for restlet.xml and this is why i get StackOverFlowError.

have you faced this problem before? i'm using camel 2.10.0 and restlet 2.1-M7, but i've tried camel 2.10.2 and all restlet version from 2.0 up to 2.1-M7.

one suggestion: i think that when using SpringServerServlet we need to override this init(Component) to do just the relevant stuff without adding war protocol as you do for getComponent, because there is no need to lookup restlet.xml. we rely on spring to inject our component or application we we are in this usecase. may be i missed something, but why you add a war protocol even when using SpringServerServlet?

thanks in advance for you help.

thboileau commented 11 years ago

Hello,

this is the first we get such error message, especially regarding the extension for Spring. Do you have any sample test case?

may be i missed something, but why you add a war protocol even when using SpringServerServlet? Such protocol may be used in order to configure a Directory that serves static files (or templates, consider the ContextTemplateLoader class from the "freemarker" extension) from the war itself (which could be kept as a compressed file or uncompressed).

Best regards, Thierry Boileau

thboileau commented 11 years ago

Hello,

I've tested camel2.10.2+restlet2.0.15+spring3.0.7, and it works for me.

Best regards, Thierry Boileau