2

xml でファイルを読み取って、HTTP4 を使用して URL に投稿しようとしています。ただし、次の例外が発生し続けます。

LinuxでJDK 1.7を使用して、Apache Camelバージョン2.11.0を使用しています

コードは次のとおりです。

   public static void main(String args[]) throws Exception {
        // create CamelContext
        CamelContext context = new DefaultCamelContext();

        // add our route to the CamelContext
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("file:/home/projects/camelinaction-source/chapter1/file-copy/data/templates")
                .convertBodyTo(String.class)
                .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
                .to("http4://testserver:8080/rest/test")
                .setHeader(Exchange.FILE_NAME, constant("response.xml"))
                .to("file:/home/projects/hyperlocal");
            }
        });

        // start the route and let it do its work
        context.start();
        Thread.sleep(10000);

        // stop the CamelContext
        context.stop();
    }

ここに例外があります。

    org.apache.camel.util.ObjectHelper.notNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: An exception occured while executing the Java class. null
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. null
    at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:338)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 17 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoSuchMethodError: org.apache.camel.util.ObjectHelper.notNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
    at org.apache.camel.component.http.HttpEndpoint.createHttpClient(HttpEndpoint.java:104)
    at org.apache.camel.component.http.HttpProducer.<init>(HttpProducer.java:72)
    at org.apache.camel.component.http.HttpEndpoint.createProducer(HttpEndpoint.java:93)
    at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:391)
    at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:114)
    at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:145)
    at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:175)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:358)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1064)
    at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
    at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:153)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:85)
    at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:938)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.processor.UnitOfWorkProcessor.doStart(UnitOfWorkProcessor.java:88)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
    at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
    at org.apache.camel.impl.RouteService.startChildService(RouteService.java:322)
    at org.apache.camel.impl.RouteService.warmUp(RouteService.java:151)
    at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:1986)
    at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1914)
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1702)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1583)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1444)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1412)
    at camelinaction.FileCopierWithCamel.main(FileCopierWithCamel.java:52)
    ... 6 more

これがpom.xmlにあるmavenの依存関係です

<dependencies>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-core</artifactId>
</dependency>
<dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-http4</artifactId>
      <version>2.11.0</version>
</dependency>
4

1 に答える 1

8

クラスパスに Camel JAR のバージョンが混在しているように聞こえます。すべての Camel JAR が同じバージョンであることを再確認できますか?

また、クラスパスに camel-http4 JAR とその依存関係が必要です。

于 2013-05-23T05:39:33.007 に答える