Hi

Ah that is because they are ordered, eg as specified here in the model class
https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/model/rest/RestConfigurationDefinition.java

Btw you ought also to be able to set the servletName on the
component-level as well via the componentProperty. But in this case it
doesn't matter very much either it was configured via rest-dsl.



On Mon, Nov 13, 2017 at 6:36 PM,  <karaf-u...@avionicengineers.com> wrote:
> Hi Claus,
>
> Thanks for your reply. Currently I don't explicitly instantiate the
> ServletComponent either by DSL or code but have been relying on 'Camel
> Magic' to do this for me, is it recommended that I explicitly create the
> component?
>
> I also discovered this solution to my problem. Use this:
>
> <restConfiguration component="servlet" bindingMode="json"
> contextPath="/camel-example-servlet-rest-blueprint/rest"
>                            port="8181">
>             <endpointProperty key="servletName" value="timeServlet" />
>             <dataFormatProperty key="prettyPrint" value="true"/>
> </restConfiguration>
>
> Instead of this:
>
> <restConfiguration component="servlet" bindingMode="json"
> contextPath="/camel-example-servlet-rest-blueprint/rest"
>                            port="8181">
>             <dataFormatProperty key="prettyPrint" value="true"/>
>             <endpointProperty key="servletName" value="timeServlet" />
> </restConfiguration>
>
>
> The crucial difference being the placement of <endpointProperty> before the
> <dataFormatProperty> tag.
>
> Kerry
>
>
> On 13/11/17 07:35, Claus Ibsen wrote:
>>
>> Hi
>>
>> Configure it as a <bean id="servlet" class="...ServletComponent">
>> where you can set the servlet name as a property
>>
>> On Sun, Nov 12, 2017 at 8:58 PM, JT <karaf-u...@avionicengineers.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I am trying to create two independent Camel Contexts with Camel blueprint
>>> (as two separate bundles) that will be deployed into the same OSGi
>>> container, exactly the same as described here:
>>>
>>>
>>> https://stackoverflow.com/questions/40271292/duplicate-servletname-detected-in-apache-camel-blueprint-based-osgi-bundles
>>>
>>> I also have encountered the same issue as described in that question,
>>> namely
>>> that the two CamelHttpTransportServlet instances are created with the
>>> same
>>> default name of 'CamelServlet'. The obvious solution is to set the
>>> servletName as a property to OsgiServletRegisterer however this then
>>> results
>>> in a HTTP 404 error when one of the URLs is called.
>>>
>>> I've traced it down to the ServletComponent class. It has a 'servletName'
>>> property that is set to 'CamelServlet' by default thus is registered in
>>> HttpRegistry under a different name to that specified to the
>>> OsgiServletRegisterer. I've verified this by debugging around the
>>> creation
>>> of Servletcomponent and manually setting the same setting name - I no
>>> longer
>>> get the 404 error.
>>>
>>> The solution seems to therefore be to configure the servletName on the
>>> ServletComponent but I cannot find anyway to do this. I've referred to:
>>>
>>> http://camel.apache.org/servlet.html
>>>
>>> where it describes a 'servletName' option but cannot specify this in my
>>> blueprint XML file, eg the '<restConfiguation>' tag doesn't take such an
>>> attribute nor can I specify it as a property.
>>>
>>> Is there a way, using the blueprint XML I can specify the 'servletName'?
>>>
>>> Thanks, Kerry
>>>
>>
>>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to