You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ztesoft <nj...@hotmail.com> on 2010/01/09 07:28:58 UTC

How to import camel in a java application program

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.


Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
Yes, you are right. The next step is transfer the inputstream to other
objects.

Thank you for all of your help.


willem.jiang wrote:
> 
> The code looks good, I just found you used
>  >> (camel-core-2.1.0.jar,
>  >> camel-http-2.1.0.jar,
>  >> camel-spring-2.1.0.jar, camel-test-2.1.0.jar)
> 
> Please put camel-jetty-2.1.0.jar into you CLASSPATH.
> 
> Willem
> 
> 
> ztesoft wrote:
>> Sure.
>> 
>> public class HttpToFileRoute {
>> 
>>     public static void main(String args[]) throws Exception {
>>         // START SNIPPET: e1
>>         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);
>>         context.stop();
>>     }
>> }
>> 
>> 
>> This is all my code.
>> 
>> 
>> 
>> willem.jiang wrote:
>>> Can I see the code that you start up the camel context and camel route ?
>>> Maybe you miss something.
>>>
>>> Willem
>>>
>>> ztesoft wrote:
>>>> yes, I used camel2.10 jar files(camel-core-2.1.0.jar,
>>>> camel-http-2.1.0.jar,
>>>> camel-spring-2.1.0.jar, camel-test-2.1.0.jar)
>>>>
>>>> I just wrote a java application program, and import needed jar files
>>>> for
>>>> program library. 
>>>> Actually, I don't know how to deploy these jar files to an OSGi
>>>> container.
>>>>
>>>>
>>>> willem.jiang wrote:
>>>>> 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 <nj...@hotmail.com>
>>>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>>>> 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
>>>>>>>>>>>>> <nj...@hotmail.com>
>>>>>>>>>>>>> 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
>>>>>>>>>
>>>>>>>>>
>>>>>
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27105831.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by Morgan Hautman <mo...@gmail.com>.
Hi,

If you're using maven,

<dependency>
     <groupId>org.apache.httpcomponents</groupId>
     <artifactId>httpclient</artifactId>
     <version>4.4</version>
</dependency>


On 26/02/2015 10:03, imranrazakhan wrote:
> Hi, I used same example but its giving following error
>
> public void configure() {
> 		
> 		from("jetty:http://localhost:8181/mytestservice").process(
> 				new Processor() {
> 					@Override
> 					public void process(Exchange exchange) throws Exception {
> 						String message = exchange.getIn().getBody(String.class);
> 						System.out.println("Hello Mr :" + message);
> 						exchange.getOut().setBody("Hello world Mr " + message);
> 					}
> 				});
> 	}
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpConnectionManager
>          at java.lang.Class.getDeclaredConstructors0(Native Method)
>          at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
>          at java.lang.Class.getConstructor0(Unknown Source)
>          at java.lang.Class.newInstance(Unknown Source)
>          at
> org.apache.camel.util.ObjectHelper.newInstance(ObjectHelper.java:1258)
>
> Above mentioned jars are in my class-path
>
> Manifest-Version: 1.0
> Main-Class: com.my.test.jetty.MainApp
> Class-path: camel-core-2.13.1.jar
>   slf4j-api-1.6.6.jar
>   log4j-1.2.17.jar
>   slf4j-log4j12-1.7.7.jar
>   camel-spring-2.13.1.jar
>   camel-jetty-2.13.1.jar
>   camel-http-2.13.1.jar
>   camel-test-2.13.1.jar
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp471924p5763196.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by imranrazakhan <im...@gmail.com>.
Hi, I used same example but its giving following error

public void configure() {
		
		from("jetty:http://localhost:8181/mytestservice").process(
				new Processor() {
					@Override
					public void process(Exchange exchange) throws Exception {
						String message = exchange.getIn().getBody(String.class);
						System.out.println("Hello Mr :" + message);
						exchange.getOut().setBody("Hello world Mr " + message);
					}
				});
	}

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/httpclient/HttpConnectionManager
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at
org.apache.camel.util.ObjectHelper.newInstance(ObjectHelper.java:1258)

Above mentioned jars are in my class-path

Manifest-Version: 1.0
Main-Class: com.my.test.jetty.MainApp
Class-path: camel-core-2.13.1.jar 
 slf4j-api-1.6.6.jar 
 log4j-1.2.17.jar 
 slf4j-log4j12-1.7.7.jar 
 camel-spring-2.13.1.jar 
 camel-jetty-2.13.1.jar 
 camel-http-2.13.1.jar 
 camel-test-2.13.1.jar 




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp471924p5763196.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to import camel in a java application program

Posted by Willem Jiang <wi...@gmail.com>.
The code looks good, I just found you used
 >> (camel-core-2.1.0.jar,
 >> camel-http-2.1.0.jar,
 >> camel-spring-2.1.0.jar, camel-test-2.1.0.jar)

Please put camel-jetty-2.1.0.jar into you CLASSPATH.

Willem


ztesoft wrote:
> Sure.
> 
> public class HttpToFileRoute {
> 
>     public static void main(String args[]) throws Exception {
>         // START SNIPPET: e1
>         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);
>         context.stop();
>     }
> }
> 
> 
> This is all my code.
> 
> 
> 
> willem.jiang wrote:
>> Can I see the code that you start up the camel context and camel route ?
>> Maybe you miss something.
>>
>> Willem
>>
>> ztesoft wrote:
>>> yes, I used camel2.10 jar files(camel-core-2.1.0.jar,
>>> camel-http-2.1.0.jar,
>>> camel-spring-2.1.0.jar, camel-test-2.1.0.jar)
>>>
>>> I just wrote a java application program, and import needed jar files for
>>> program library. 
>>> Actually, I don't know how to deploy these jar files to an OSGi
>>> container.
>>>
>>>
>>> willem.jiang wrote:
>>>> 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 <nj...@hotmail.com>
>>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>>>>> 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
>>>>>>>>
>>>>>>>>
>>>>
>>
>>
> 


Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
Sure.

public class HttpToFileRoute {

    public static void main(String args[]) throws Exception {
        // START SNIPPET: e1
        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);
        context.stop();
    }
}


This is all my code.



willem.jiang wrote:
> 
> Can I see the code that you start up the camel context and camel route ?
> Maybe you miss something.
> 
> Willem
> 
> ztesoft wrote:
>> yes, I used camel2.10 jar files(camel-core-2.1.0.jar,
>> camel-http-2.1.0.jar,
>> camel-spring-2.1.0.jar, camel-test-2.1.0.jar)
>> 
>> I just wrote a java application program, and import needed jar files for
>> program library. 
>> Actually, I don't know how to deploy these jar files to an OSGi
>> container.
>> 
>> 
>> willem.jiang wrote:
>>> 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 <nj...@hotmail.com>
>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27105625.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by Willem Jiang <wi...@gmail.com>.
Can I see the code that you start up the camel context and camel route ?
Maybe you miss something.

Willem

ztesoft wrote:
> yes, I used camel2.10 jar files(camel-core-2.1.0.jar, camel-http-2.1.0.jar,
> camel-spring-2.1.0.jar, camel-test-2.1.0.jar)
> 
> I just wrote a java application program, and import needed jar files for
> program library. 
> Actually, I don't know how to deploy these jar files to an OSGi container.
> 
> 
> willem.jiang wrote:
>> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com>
>>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>>> 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
>>>>>>
>>>>>>
>>>>
>>
>>
> 


Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
yes, I used camel2.10 jar files(camel-core-2.1.0.jar, camel-http-2.1.0.jar,
camel-spring-2.1.0.jar, camel-test-2.1.0.jar)

I just wrote a java application program, and import needed jar files for
program library. 
Actually, I don't know how to deploy these jar files to an OSGi container.


willem.jiang wrote:
> 
> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com>
>>>>>>> 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 <nj...@hotmail.com>
>>>>>>>>> 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
>>>>>
>>>>>
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27105500.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by Willem Jiang <wi...@gmail.com>.
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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com>
>>>>>>>> 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
>>>>
>>>>
>>
>>
> 


Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com>
>>>>>>> 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
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27105162.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by Willem Jiang <wi...@gmail.com>.
Camel 2.2.0 is under development, you can use the latest camel 2.1.0 for 
testing :)

Willem

ztesoft wrote:
> Otherwise, I can not download the camel 2.2.0 using the camel Download
> Mirrors. 
> Can you give me a usable URL?
> 
> 
> 
> 
> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com>
>>>>>>>> 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
>>>>
>>>>
>>
>>
> 


Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
Otherwise, I can not download the camel-http2.2.0 using the camel Download
Mirrors. 
Can you give me a usable URL?




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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com>
>>>>>>> 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
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27105318.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by Willem Jiang <wi...@gmail.com>.
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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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
>>
>>
> 


Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp27085959p27104802.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to import camel in a java application program

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jan 9, 2010 at 11:23 AM, ztesoft <nj...@hotmail.com> 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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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

Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
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?







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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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.


Re: How to import camel in a java application program

Posted by Stephen Gargan <st...@gmail.com>.
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 <nj...@hotmail.com> 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 <nj...@hotmail.com> 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.
>
>

Re: How to import camel in a java application program

Posted by ztesoft <nj...@hotmail.com>.
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 <nj...@hotmail.com> 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.


Re: How to import camel in a java application program

Posted by imranrazakhan <im...@gmail.com>.
I am running this example standalone. 

I am able to run this example by adding other jars also, but to run
standalone above mentioned jars are not suffice.



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-import-camel-in-a-java-HTTP-server-application-program-tp471924p5763206.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to import camel in a java application program

Posted by Stephen Gargan <st...@gmail.com>.
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 <nj...@hotmail.com> 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.
>
>