java - 加载 spring camel 上下文时出错(类型不匹配)

标签 java spring apache-camel apache-servicemix

我在一个带有 spring camel 上下文、一个路由和一个测试的小项目中使用 Fuse IDE (Eclipse)。我放了一个额外的 xml 来定义测试执行环境。

当我运行测试时,加载上下文 bean 信息时类型不匹配失败(当实例化 bean 上下文的 PropertyDescriptor 类时,setter 类型是 org.apache.camel.spring.SpringCamelContext,getter 类型是 org.apache.camel .model.ModelCamelContext...

原来的异常是:“java.beans.IntrospectionException:读写方法之间的类型不匹配”

测试代码是这样的:

public class TestDBRoute extends CamelSpringTestSupport {   

@DirtiesContext //reload context
@Test
public void testPoll() throws Exception {
    //context.start();
    System.out.println("comenzo");
    Thread.sleep(1000);
    System.out.println("termino");
    //context.stop();
    assertEquals("first", 1, 1);
}

@Override
protected AbstractApplicationContext createApplicationContext() {
    return new ClassPathXmlApplicationContext("classpath:/com/test-camel-context.xml");
}
}

Camel 上下文代码是:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

<camelContext xmlns="http://camel.apache.org/schema/spring">
        <packageScan>
            <package>com.test.fuse.routes</package>
        </packageScan>
</camelContext>
</beans>

路由代码是空的,它只是扩展了RouteBuilder并覆盖了configure方法。

我在 ubuntu 上使用 OpenJDK 1.6.0_24。

如果您需要其他东西,请询问。

谢谢

最佳答案

我只是清理了工作区并在 pom.xml 上将我的 spring 版本从 2.5.4 更改为 2.5.6,一切正常。

感谢 Claud Ibsen 和 Babak Vahdat 的帮助。

关于java - 加载 spring camel 上下文时出错(类型不匹配),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12133883/

相关文章:

java - 创建名称为 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping' 的 bean 时出错

java - @transaction - 回滚失败

java - JSESSION/HTTPSession 与应用程序制作的 session ID

java - Camel Direct 端点异常

java - Camel 和 Jackson 依赖性问题

java - 如何使用 Java 获取 git 信息?

java - 如何覆盖 Mockito 中 unstubbed void 方法的默认行为?

java - 使用接口(interface)的抽象类或公共(public)方法

java - 1 个 ItemReader、2 个 SQL 查询、jdbcTemplate?

apache-camel - 忽略 Camel Spring Boot 中的一些 Route Builder 组件