Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 3889 invoked from network); 13 Aug 2009 08:26:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Aug 2009 08:26:32 -0000 Received: (qmail 36610 invoked by uid 500); 13 Aug 2009 08:26:38 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 36558 invoked by uid 500); 13 Aug 2009 08:26:38 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 36548 invoked by uid 99); 13 Aug 2009 08:26:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Aug 2009 08:26:38 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of willem.jiang@gmail.com designates 209.85.198.250 as permitted sender) Received: from [209.85.198.250] (HELO rv-out-0708.google.com) (209.85.198.250) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Aug 2009 08:26:27 +0000 Received: by rv-out-0708.google.com with SMTP id l33so1420836rvb.4 for ; Thu, 13 Aug 2009 01:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=k/J/zsiuZ8TuipWqkMo4bOkSenS2GMysmxCyp1cz0oA=; b=LApmgXqUWtQFyIdfrkRNHy1oy963R1ghBlJOLxKEjvSj7RQSIcwu9hurMtyacdQez0 Td3USCTpI1jyJZr6p8njcpirZHKSqYOQdBzYCVWuf1R+LF7ebOAHKmgf/YnLI9yRVdwo Xc9rgIFHmEGTbkdkA66fUgMPSVSiUpHsQjsBY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=cLhYLDKHTGjmCG6tHJLNNLXweGudvGFGIK7rM0gthhluu/7l4XYBrBLSSgfJjWAAGP P0a82mYRnJcdSPpZF2DxBg8+J3r4D+mLEXFRVLaurm2reEsuL5CAEr6RxZr8lFs2GpBl FZVXox8kJr0Gk8u15S1LbsrnfD2QggEP3WT2w= Received: by 10.140.128.6 with SMTP id a6mr435478rvd.153.1250151965745; Thu, 13 Aug 2009 01:26:05 -0700 (PDT) Received: from ?192.168.0.158? ([123.116.27.89]) by mx.google.com with ESMTPS id g22sm176472rvb.12.2009.08.13.01.26.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 13 Aug 2009 01:26:04 -0700 (PDT) Message-ID: <4A83CE17.5060100@gmail.com> Date: Thu, 13 Aug 2009 16:25:59 +0800 From: Willem Jiang User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: users@camel.apache.org Subject: Re: How to create a Servlet component? References: <24909157.post@talk.nabble.com> <24909247.post@talk.nabble.com> <4A80B5D4.2000303@gmail.com> <24909831.post@talk.nabble.com> <4A80C18E.8060300@gmail.com> <24921644.post@talk.nabble.com> <4A824D74.1090806@gmail.com> <24940161.post@talk.nabble.com> In-Reply-To: <24940161.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, I just wrote a simple unit test which is based on your test case, I got the same error. That is because the camel context is created before the servlet instance is initialized. So I added an init parameter in the CamelHttpTransportServlet to consumer the spring application context configure file, and make sure the camel context is created after servlet initialization. You can find the example here. http://svn.apache.org/viewvc?rev=803805&view=rev Willem janylj wrote: > Sure. > > camel-config.xml: > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> > > > > package.contains.route.builder > > > > web.xml: > xmlns="http://java.sun.com/xml/ns/javaee" > xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" > xsi:schemaLocation="http://java.sun.com/xml/ns/javaee > http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" > id="WebApp_ID" version="2.5"> > > > CamelServlet > > org.apache.camel.component.servlet.CamelHttpTransportServlet > > > matchOnUriPrefix > true > > 1 > > > > CamelServlet > /services/* > > > > > contextConfigLocation > classpath:camel-config.xml > > > > > > org.springframework.web.context.ContextLoaderListener > > > > RouteBuilder java class: > public class ServletToJmsRouteBuilder extends RouteBuilder { > > public void configure() throws Exception { > from("servlet:///hello?servletName=CamelServlet").process(new Processor() > { > > public void process(Exchange exchange) { > String contentType = (String) > exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class); > String path = (String) > exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class); > String charsetEncoding = (String) > exchange.getIn().getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class); > exchange.getOut().setHeader(Exchange.CONTENT_TYPE, > contentType + "; charset=UTF-8"); > exchange.getOut().setHeader("PATH", path); > exchange.getOut().setBody("Hello World"); > } > }); > } > } > > Please let me know if you need anything else. Thanks a lot. > > > willem.jiang wrote: >> Hi, >> >> Can you show me the camel-config.xml? >> A simple demo help me debug the issue. >> >> Willem >> >> janylj wrote: >>> willem.jiang wrote: >>>> If you create the servlet component, you need to specify the servlet >>>> which the component will attach to. >>>> >>> class="org.apache.camel.component.servlet.ServletComponent"> >>>> >>>> >>>> >>>> >>>> >>> doesn't work, because Tomcat starts error said, >>> >>> Caused by: org.springframework.beans.InvalidPropertyException: Invalid >>> property 'servletName' of bean class >>> [org.apache.camel.component.servlet.ServletComponent]: No property >>> 'servletName' found >>> >>> >>> willem.jiang wrote: >>>> You don't need to specify the servlet component in spring, if there is >>>> only one camel servlet created in the web context. >>>> >>>> >>> doesn't work, because Tomcat starts error said, >>> >>> Caused by: java.lang.IllegalArgumentException: Can't find the deployied >>> servlet, please set the ServletComponent with it or delopy a >>> CamelHttpTransportServlet int the web container >>> >>> What I am missing? Please note that I am using Spring >>> ContextLoaderListener. >>> Thanks a lot. >>> >>> my web.xml, >>> >>> >>> >>> contextConfigLocation >>> classpath:camel-config.xml >>> >>> >>> >>> >>> >>> org.springframework.web.context.ContextLoaderListener >>> >>> >>> >>> CamelServlet >>> >>> org.apache.camel.component.servlet.CamelHttpTransportServlet >>> >>> >>> matchOnUriPrefix >>> true >>> >>> 1 >>> >>> >>> >>> CamelServlet >>> /services/* >>> >>> >>> >>> >> >> >