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 <[email protected]> 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 <[email protected]>
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 <[email protected]>
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







Reply via email to