[
https://issues.apache.org/jira/browse/CAMEL-5312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15828832#comment-15828832
]
Matthew Casperson edited comment on CAMEL-5312 at 1/18/17 9:47 PM:
-------------------------------------------------------------------
I know this bug is years old and not related to camel, but we had a similar
issue with Restlet that others might appreciate some insight into given that
this is now a Google result.
What was happening was that our REST DSL routes would randomly return a 404
after a server restart. The steps involved were:
1. Boot the Camel app
2. Hit a REST DSL route like /api/status before all routes were started
3. Additional routes were started
4. REST DSL endpoints like /api/doSomething were being added under paths like
/api/status/doSomething. You would see messages like this in the logs :
[Server:main-server] INFO | default task-10 | SpringServerServlet: [Restlet]
Attaching restlet: org.apache.camel.component.restlet.MethodBasedRouter@3e7385f
to URI: /api/status/doSomething
What was happening was that the path of the first REST DSL endpoint to be
requested was now being added to new REST DSL endpoints that were in the
process of being created and exposed. As a result, we were getting 404 errors
when we tried to access the expected URL.
We were creating an instance of org.restlet.Component as a Spring bean, and
manually calling the start() method when the Component is created seems to have
resolved the issue for us.
was (Author: mcasperson):
I know this bug is years old and not related to camel, but we had a similar
issue with Restlet that others might appreciate some insight into.
What was happening was that our REST DSL routes would randomly return a 404
after a server restart. The steps involved were:
1. Boot the Camel app
2. Hit a REST DSL route like /api/status before all routes were started
3. Additional routes were started
4. REST DSL endpoints like /api/doSomething were being added under paths like
/api/status/doSomething. You would see messages like this in the logs :
[Server:main-server] INFO | default task-10 | SpringServerServlet: [Restlet]
Attaching restlet: org.apache.camel.component.restlet.MethodBasedRouter@3e7385f
to URI: /api/status/doSomething
What was happening was that the path of the first REST DSL endpoint to be
requested was now being added to new REST DSL endpoints that were in the
process of being created and exposed. As a result, we were getting 404 errors
when we tried to access the expected URL.
We were creating an instance of org.restlet.Component as a Spring bean, and
manually calling the start() method when the Component is created seems to have
resolved the issue for us.
> Adding Restlet routes with relative paths to Apache Camel context does NOT
> work after I send first request to restlet route
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-5312
> URL: https://issues.apache.org/jira/browse/CAMEL-5312
> Project: Camel
> Issue Type: Bug
> Components: camel-restlet
> Affects Versions: 2.9.1
> Environment: Grails, Apache Camel
> Reporter: Amit Patel
> Assignee: Claus Ibsen
> Fix For: 2.10.0
>
> Attachments: RestletSpringServlet.java
>
>
> Adding Restlet routes with relative paths to Apache Camel context does NOT
> work after I send first request to restlet route.
> 1) Add Restlet route restletRoute1 with relative path to Apache Camel context
> 2) Send a request to restletRoute1 (works)
> 3) Add a route restletRoute2 with relative path to Apache Camel context
> 4) Send a request to restletRoute2 (does not works). RestletServlet
> does not find the restlet endpoint and return Not Found message.
> when I checked jconsole It saw the restletRoute1 and restletRoute2 started
> successfully. If I add restletRoute1 and restletRoute2 then send a
> request to restletRoute1 and restletRoute2 both works. Our
> application supports add route on-the-fly feature, so we don't have
> to start the application every time when we add a new route. Because of
> the above issue we can't integrate restlet to our application.
> Routes
> -------
> <routes xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="restlet:/restletRoute1"/>
> <setHeader headerName="Content-Type">
> <constant>text/plain</constant>
> </setHeader>
> <setBody>
> <constant>restletRoute1</constant>
> </setBody>
> </route>
> <route>
> <routes xmlns="http://camel.apache.org/schema/spring">
> <route>
> <from uri="restlet:/restletRoute2"/>
> <setHeader headerName="Content-Type">
> <constant>text/plain</constant>
> </setHeader>
> <setBody>
> <constant>restletRoute2</constant>
> </setBody>
> </route>
> <route>
> libs
> -----
> 'org.apache.camel:camel-restlet:2.9.1'
> 'org.restlet.jee:org.restlet.ext.spring:2.0.13'
> Web.xml
> -----------
> <servlet>
> <servlet-name>RestletServlet</servlet-name>
>
> <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class>
> <init-param>
> <param-name>org.restlet.component</param-name>
> <param-value>restletComponent</param-value>
> </init-param>
> </servlet>
> <servlet-mapping>
> <servlet-name>RestletServlet</servlet-name>
> <url-pattern>/rs/*</url-pattern>
> </servlet-mapping>
> Resources.groovy
> -----------------
> restletComponent(org.restlet.Component)
> restletComponentService(org.apache.camel.component.restlet.RestletComponent,
> ref("restletComponent"))
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)