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 <njche...@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 <njche...@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.

Reply via email to