1

我正在尝试使用 Camel 和 Spring 将数据从 Mysql (5.1.37) 复制到 Oracle 数据库 (11)。配置如下所示:

<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
 <route>
  <from uri="direct:start" />
  <to uri="sql:select id, name, description from user?dataSourceRef=fromDataSource" />
  <to uri="sql:insert into user (id, name, description) values (#, #, #)?dataSourceRef=toDataSource"/>
 </route>
</camelContext>

我正在使用以下代码运行它:

public void fetchUsers() throws Exception {
    CamelContext context = (CamelContext) SpringUtil.getBean("camelContext");
    ProducerTemplate template = context.createProducerTemplate();
    context.start();
    template.sendBody("direct:start", "test");
}

但是,我遇到了一个例外:

10:04:24,208 ERROR [main] DefaultErrorHandler - Failed delivery for (MessageId: ID-UNISTHDW177-55800-1338278663095-0-3 on ExchangeId: ID-UNISTHDW177-55800-1338278663095-0-2). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: [{id=1, name=Carl, description=Developer}, {id=2, name=Lars, description=Developer}]]
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: [{id=1, name=Carl, description=Developer}, {id=2, name=Lars, description=Developer}]]
    at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1237)
    at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:282)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:64)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)
    at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:333)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223)
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
    at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
    at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:50)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
    at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
    at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
    at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
    at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:352)
    at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:324)
    at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:223)
    at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:324)
    at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:169)
    at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:111)
    at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:124)
    at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:131)
    at com.unibet.finance.reporting.camel.GordiumFetcherTest.camelShouldFetchGordiumAttributes(GordiumFetcherTest.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.AbstractMethodError
    at org.apache.camel.component.sql.SqlProducer$1.doInPreparedStatement(SqlProducer.java:50)
    at org.apache.camel.component.sql.SqlProducer$1.doInPreparedStatement(SqlProducer.java:48)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:614)
    at org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:48)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    ... 70 more

我在这里想念什么?

4

1 回答 1

0

当您的 JDBC 驱动程序实现旧版本的 JDBC API 时会发生此错误,然后是 JRE 中可用的用于运行应用程序的版本(Camel 需要该版本)。在这种情况下,您需要 JDBC API 版本 >= 3。

应该解决的问题是将您的 Oracle 驱动程序更新到最新版本(支持您的数据库)。

您在评论中写道您已经尝试更新驱动程序版本(无效)。您可能在应用服务器的 lib/ext 目录中的某个位置获得了旧版本的 Oracle 驱动程序。可能您正在使用 Maven 来获取 Oracle JDBC 驱动程序,而另一个驱动程序实例由应用程序服务器提供。

不是 Camel 问题,而是 JDBC 驱动程序和服务器类路径问题。修复您的驱动程序类路径问题,Camel 将完成他的工作:)。

于 2012-05-30T10:04:51.063 回答