我正在尝试使用xml读取文件,然后使用HTTP4将其发布到URL.但是继续得到以下异常.
我正在使用Apache Camel版本2.11.0,在Linux上使用JDK 1.7
这是代码:
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();
}
Run Code Online (Sandbox Code Playgroud)
这是例外.
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 …Run Code Online (Sandbox Code Playgroud) apache-camel ×1