You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by apostle <pa...@gmail.com> on 2015/06/03 09:53:36 UTC

migration of a servlet from servicemix v3.1.4 to v5.3.2

Faced with a problem during migration from SM v5.1.4 to v5.3.2. The code
below works perfectly on v5.1.4. The servlet is registred with a key
"/CamelServlet/" in the HttpRegistry and it has a single provider which is
/CamelHttpTransportServlet /and a single consumer
/Consumer[servlet:///?matchOnUriPrefix=true]/.

On the version 5.3.2 for some reason there are two HttpRegistries are
registred. The first one again with a key "/CamelServlet/" and this registry
has a consumer /Consumer[servlet:///?matchOnUriPrefix=true]/ which is fine,
but the provider is registered for a different instance of HttpRegistry with
a key /org.ops4j.pax.web.service.spi.model.ServletModel-XXX/ (where /XXX /is
a generated integer). So now I have two HttpRegistries, one has providers,
another one consumers. With this the "/mainRoute/" is never called because
consumers are registered not for the CamelServlet but for some another
HttpRegistry. So when a request comes, the code in the service method of the
CamelServlet.class which is marked with {1} will return null for a consumer
and no route will be called.

Does anyone has an idea what is wrong and how I can fix that? Thank you

*CamelServlet*

package org.apache.camel.component.http;

public class CamelServlet extends HttpServlet {
.........................

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
        log.trace("Service: {}", request);

        // Is there a consumer registered for the request.
        HttpConsumer consumer = resolve(request); //{1} resolve a consumer
        if (consumer == null) {
            log.debug("No consumer to service request {}", request);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }    
    }

....................

}

*Camel context*

   xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
                       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd

                       http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
                       http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
                       http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd"
    >


<bean id="camelServlet"
class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>

<osgi:service ref="camelServlet">
    <osgi:interfaces>
        <value>javax.servlet.Servlet</value>
        <value>org.apache.camel.component.http.CamelServlet</value>
    </osgi:interfaces>
    <osgi:service-properties>
        <entry key="alias" value="/test" />
        <entry key="matchOnUriPrefix" value="true" />
        <entry key="servlet-name" value="CamelServlet"/>
    </osgi:service-properties>
</osgi:service>

<camelContext xmlns="http://camel.apache.org/schema/spring"
streamCache="true" trace="false">

    <route id="mainRoute">
        <from uri="servlet:///?matchOnUriPrefix=true"/>
        <log message="Process mainRoute"/>
    </route>

</camelContext>



--
View this message in context: http://servicemix.396122.n5.nabble.com/migration-of-a-servlet-from-servicemix-v3-1-4-to-v5-3-2-tp5722667.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.