Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 4594 invoked from network); 11 Jan 2010 03:12:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Jan 2010 03:12:56 -0000 Received: (qmail 47937 invoked by uid 500); 11 Jan 2010 03:12:55 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 47882 invoked by uid 500); 11 Jan 2010 03:12:54 -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 47872 invoked by uid 99); 11 Jan 2010 03:12:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2010 03:12:54 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of willem.jiang@gmail.com designates 209.85.211.175 as permitted sender) Received: from [209.85.211.175] (HELO mail-yw0-f175.google.com) (209.85.211.175) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2010 03:12:44 +0000 Received: by ywh5 with SMTP id 5so44691577ywh.11 for ; Sun, 10 Jan 2010 19:12:23 -0800 (PST) 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=Uo5MXq0mh1jwG0yVVNsbNHvWA1hX2ZRw+s/xbi/KHls=; b=j+GaUDgjcoPxJTF2PjKYt02Mnz8ote7lpNgbwOLFg3t0nAMCRJLfbsasevjfc9t8Ni YP5sDHp366Yce/CbcV2exZcqmI3L76/qtVKKEsDtI7T0SF0Lri6pLe5ZOJbXOyMnnRkU Urla3TD3WsE8bIS9z5WXwxUF7O54km78GVdn8= 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=i/vkFchRda2ppB+OTdpFx/brXGx8mK4fRFZMI4fwzXF+BSw7PtAStiHASYEwuJ2umi gHJw2TPd4lxha9SyOneFvhNX+k5z1vAb4LwDaJawBSOCMTr6Db6D3wM/FAHlopyFoDQh V+F5xwKda2fhYS6gzTAQfyco78Vt5UKSix3ho= Received: by 10.91.74.18 with SMTP id b18mr5190430agl.39.1263179543791; Sun, 10 Jan 2010 19:12:23 -0800 (PST) Received: from ?192.168.0.158? ([125.34.15.54]) by mx.google.com with ESMTPS id 15sm11818892gxk.12.2010.01.10.19.12.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 10 Jan 2010 19:12:22 -0800 (PST) Message-ID: <4B4A9711.4000908@gmail.com> Date: Mon, 11 Jan 2010 11:12:17 +0800 From: Willem Jiang User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: users@camel.apache.org Subject: Re: How to import camel in a java application program References: <27085959.post@talk.nabble.com> <55f2e4a81001082312l19a632f8u4b85600e9f7807b1@mail.gmail.com> <27086149.post@talk.nabble.com> <55f2e4a81001090044x29a677e6x48f92bb6696214c2@mail.gmail.com> <27087072.post@talk.nabble.com> <5380c69c1001090230w338151bcx85ec9fa5a4f745df@mail.gmail.com> <27104802.post@talk.nabble.com> <4B4A878F.90204@gmail.com> <27105162.post@talk.nabble.com> In-Reply-To: <27105162.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit If you are using camel-core-2.1.0.jar and camel-spring 2.1.0.jar, using camel-http-2.1.0.jar should be OK. BTW, I assume you don't deploy these jar to an OSGi container. Willem ztesoft wrote: > I put camel-http-2.1.0.jar into my classpath. > > Are there large differences between them? > > > > willem.jiang wrote: >> Hi, >> >> Did you put org.apache.camel:camel-http:jar:2.2-SNAPSHOT into your >> CLASSPATH ? >> >> Willem >> >> ztesoft wrote: >>> Dears, >>> >>> I tried to get all the jar files mentioned in your reply. Also I found >>> there >>> miss a jar file named commons-management-1.0.jar. >>> >>> But when I run the program, the error occurs, the error message as >>> following: >>> Exception in thread "main" org.apache.camel.FailedToCreateRouteException: >>> Failed to create route route1: Route[[From[jetty:http://0.0.0.0/8080/]] >>> -> >>> [To[file:output]... because of Failed to resolve endpoint: >>> jetty://http://0.0.0.0/8080/ due to: No component found with scheme: >>> jetty >>> at >>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:141) >>> at >>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:601) >>> at >>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1156) >>> at >>> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1073) >>> at >>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1009) >>> at >>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:55) >>> at >>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:884) >>> at camelhttp.HttpToFileRoute.main(HttpToFileRoute.java:38) >>> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to >>> resolve endpoint: jetty://http://0.0.0.0/8080/ due to: No component found >>> with scheme: jetty >>> at >>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:444) >>> at >>> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:46) >>> at >>> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:154) >>> at >>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:109) >>> at >>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:115) >>> at >>> org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72) >>> at >>> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:84) >>> at >>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:630) >>> at >>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:136) >>> ... 7 more >>> Java Result: 1 >>> >>> what can I do for this error? >>> >>> >>> >>> >>> Claus Ibsen-2 wrote: >>>> On Sat, Jan 9, 2010 at 11:23 AM, ztesoft wrote: >>>>> I wrote the code as following: >>>>> public class HttpToFileRoute { >>>>> >>>>> public static void main(String args[]) throws Exception { >>>>> CamelContext context = new DefaultCamelContext(); >>>>> >>>>> context.addRoutes(new RouteBuilder() { >>>>> >>>>> public void configure() { >>>>> from("jetty:http://0.0.0.0/8080/").to("file:output"); >>>>> // set up a listener on the file component >>>>> from("file://output").process(new Processor() { >>>>> >>>>> public void process(Exchange e) { >>>>> System.out.println("Received exchange: " + >>>>> e.getIn()); >>>>> } >>>>> }); >>>>> } >>>>> }); >>>>> context.start(); >>>>> >>>>> Thread.sleep(100000); // I want to let the server works 100000 >>>>> seconds, is it correct? >>>>> context.stop(); >>>>> } >>>>> } >>>>> >>>>> but when I run the program, the error occurs. error message as >>>>> following: >>>>> Exception in thread "main" java.lang.NoClassDefFoundError: >>>>> org/mortbay/jetty/security/SslSocketConnector >>>>> at java.lang.Class.getDeclaredConstructors0(Native Method) >>>>> at >>>>> java.lang.Class.privateGetDeclaredConstructors(Class.java:2389) >>>>> at java.lang.Class.getConstructor0(Class.java:2699) >>>>> at java.lang.Class.newInstance0(Class.java:326) >>>>> at java.lang.Class.newInstance(Class.java:308) >>>>> at >>>>> org.apache.camel.util.ObjectHelper.newInstance(ObjectHelper.java:958) >>>>> at >>>>> org.apache.camel.util.ReflectionInjector.newInstance(ReflectionInjector.java:32) >>>>> at >>>>> org.apache.camel.impl.DefaultComponentResolver.resolveComponent(DefaultComponentResolver.java:82) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.getComponent(DefaultCamelContext.java:217) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:411) >>>>> at >>>>> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:46) >>>>> at >>>>> org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:154) >>>>> at >>>>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:109) >>>>> at >>>>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:115) >>>>> at >>>>> org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72) >>>>> at >>>>> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:84) >>>>> at >>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:630) >>>>> at >>>>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:136) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:601) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1156) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1073) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1009) >>>>> at >>>>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:55) >>>>> at >>>>> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:884) >>>>> at >>>>> org.apache.camel.example.jmstofile.HttpToFileRoute.main(HttpToFileRoute.java:38) >>>>> Caused by: java.lang.ClassNotFoundException: >>>>> org.mortbay.jetty.security.SslSocketConnector >>>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:200) >>>>> at java.security.AccessController.doPrivileged(Native Method) >>>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:188) >>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:307) >>>>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) >>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:252) >>>>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) >>>>> ... 25 more >>>>> >>>>> >>>>> I know there should be imported some jar files. But which files should >>>>> I >>>>> import? >>>>> Also, is the code correct? >>>>> >>>> The code appears correct. >>>> >>>> You need many jars (the ones with compile listed) from below. >>>> >>>> If you use maven then that is easy as Maven resolves the jars to use. >>>> Without maven you gotta go hunt for those jars yourself. >>>> >>>> >>>> [INFO] >>>> ------------------------------------------------------------------------ >>>> [INFO] Building Camel :: Jetty >>>> [INFO] task-segment: [dependency:list] >>>> [INFO] >>>> ------------------------------------------------------------------------ >>>> [INFO] [dependency:list] >>>> [INFO] >>>> [INFO] The following files have been resolved: >>>> [INFO] aopalliance:aopalliance:jar:1.0:test >>>> [INFO] com.sun.xml.bind:jaxb-impl:jar:2.1.12:compile >>>> [INFO] commons-codec:commons-codec:jar:1.2:compile >>>> [INFO] commons-httpclient:commons-httpclient:jar:3.1:compile >>>> [INFO] commons-logging:commons-logging:jar:1.1.1:compile >>>> [INFO] commons-logging:commons-logging-api:jar:1.1:compile >>>> [INFO] javax.activation:activation:jar:1.1:compile >>>> [INFO] javax.xml.bind:jaxb-api:jar:2.1:compile >>>> [INFO] javax.xml.stream:stax-api:jar:1.0-2:compile >>>> [INFO] junit:junit:jar:4.4:test >>>> [INFO] log4j:log4j:jar:1.2.14:test >>>> [INFO] org.apache.camel:camel-core:jar:2.2-SNAPSHOT:compile >>>> [INFO] org.apache.camel:camel-http:jar:2.2-SNAPSHOT:compile >>>> [INFO] org.apache.camel:camel-spring:jar:2.2-SNAPSHOT:test >>>> [INFO] org.apache.camel:camel-test:jar:2.2-SNAPSHOT:test >>>> [INFO] >>>> org.apache.geronimo.specs:geronimo-servlet_2.4_spec:jar:1.1.1:compile >>>> [INFO] org.fusesource.commonman:commons-management:jar:1.0:compile >>>> [INFO] org.mortbay.jetty:jetty:jar:6.1.19:compile >>>> [INFO] org.mortbay.jetty:jetty-client:jar:6.1.19:compile >>>> [INFO] org.mortbay.jetty:jetty-sslengine:jar:6.1.19:compile >>>> [INFO] org.mortbay.jetty:jetty-util:jar:6.1.19:compile >>>> [INFO] org.mortbay.jetty:jetty-util5:jar:6.1.19:compile >>>> [INFO] org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile >>>> [INFO] org.springframework:spring-aop:jar:2.5.6:test >>>> [INFO] org.springframework:spring-beans:jar:2.5.6:test >>>> [INFO] org.springframework:spring-context:jar:2.5.6:test >>>> [INFO] org.springframework:spring-core:jar:2.5.6:test >>>> [INFO] org.springframework:spring-tx:jar:2.5.6:test >>>> >>>> >>>>> >>>>> >>>>> >>>>> >>>>> Stephen Gargan wrote: >>>>>> Yes, adding the camel-jetty dependency and initiializing a route with >>>>>> >>>>>> from("jetty:http://0.0.0.0/8080/").to("file:test") >>>>>> >>>>>> will cause camel to stand up a jetty based http server. The content of >>>>>> any http request sent to '/' on the server will be written to the file >>>>>> 'test' >>>>>> >>>>>> >>>>>> On Fri, Jan 8, 2010 at 11:34 PM, ztesoft wrote: >>>>>>> Does it mean I should use jetty for HTTP server? >>>>>>> >>>>>>> >>>>>>> Stephen Gargan wrote: >>>>>>>> Take a look at the jms-to-file from the examples >>>>>>>> >>>>>>>> http://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/ >>>>>>>> >>>>>>>> Look at the JmsToFileRoute; You'll be using a jetty http endpoint in >>>>>>>> place of the jms one e.g. >>>>>>>> >>>>>>>> from("jetty:http://0.0.0.0/8080/").to("file:test") >>>>>>>> >>>>>>>> Remember, you'll need to include the camel-jetty dependency so add >>>>>>>> this to your pom. >>>>>>>> >>>>>>>> Give it a try. >>>>>>>> >>>>>>>> ste >>>>>>>> >>>>>>>> On Fri, Jan 8, 2010 at 10:28 PM, ztesoft >>>>>>>> wrote: >>>>>>>>> I write a java application program to achieve a HTTP server. Camel >>>>>>>>> is >>>>>>>>> used in >>>>>>>>> this program to receive the http requests and transfer them to a >>>>>>>>> file. >>>>>>>>> >>>>>>>>> Does anyone suggest me how to do this? >>>>>>>>> -- >>>>>>>>> View this message in context: >>>>>>>>> http://old.nabble.com/How-to-import-camel-in-a-java-application-program-tp27085959p27085959.html >>>>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>>>>> >>>>>>>>> >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27086149.html >>>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>>> >>>>>>> >>>>> -- >>>>> View this message in context: >>>>> http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27087072.html >>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>> >>>>> >>>> >>>> -- >>>> Claus Ibsen >>>> Apache Camel Committer >>>> >>>> Author of Camel in Action: http://www.manning.com/ibsen/ >>>> Open Source Integration: http://fusesource.com >>>> Blog: http://davsclaus.blogspot.com/ >>>> Twitter: http://twitter.com/davsclaus >>>> >>>> >> >> >