camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AnitaJ <javasp...@gmail.com>
Subject Newbie question
Date Wed, 12 Oct 2011 20:23:11 GMT
Hi everyone,

I am working with a camel example application. I have a web.xml file with a
mapping for CamelHttpTransportServlet. When I attached the source code to
the camelservlet, I see that the application exits with a 404 because it
could not find a HTTPConsumer. Do I need to create a HTTPConsumer explicitly
(if so, would that be in the context.xml?) ?? I must be missing something
real basic, but I have spent so much time on this and I am just about ready
to tear my hair out by the roots! If any of you can point me in the right
direction, that would be so great!!!

Thanks!!

CamelServlet


        protected void service(..
        ..
          HttpConsumer consumer = resolve(request);
            if (consumer == null) {
              log.debug("No consumer to service request {}", request);
              response.sendError(HttpServletResponse.SC_NOT_FOUND);
              return;
          }
        ..
        }

        protected HttpConsumer resolve(HttpServletRequest request) {
        String path = request.getPathInfo();
        if (path == null) {
            return null;
        }
        HttpConsumer answer = consumers.get(path);
               
        if (answer == null) {
            for (String key : consumers.keySet()) {
                if (consumers.get(key).getEndpoint().isMatchOnUriPrefix() &&
path.startsWith(key)) {
                    answer = consumers.get(key);
                    break;
                }
            }
        }
        return answer; // this is null
    }

web.xml

  <servlet>
    <servlet-name>CamelServlet</servlet-name>
   
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>context.xml</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>CamelServlet</servlet-name>
    <url-pattern>/camel/*</url-pattern>
  </servlet-mapping>

context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       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">

  <camel:camelContext id="camelContext">
    <camel:jmxAgent id="agent" disabled="true"/>
    <camel:routeBuilder ref="tutorialRouteBuilder"/>
  </camel:camelContext>

  <bean id="tutorialRouteBuilder"
class="org.apache.camel.example.gae.TutorialRouteBuilder"/>

</beans>

--
View this message in context: http://camel.465427.n5.nabble.com/Newbie-question-tp4896854p4896854.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message