我正在使用骆驼蓝图并面临休眠组件的问题。此示例在 Spring 中运行良好,但在蓝图 JBoss Fuse 6.3 V 中运行良好
提供的示例在春季并且工作正常,但蓝图中的任何示例都会有所帮助 http://camel.apache.org/hibernate-example.html
错误: org.osgi.service.blueprint.container.ComponentDefinitionException:错误设置属性:PropertyDescriptor 原因:java.lang.Exception:无法将值 org.springframework.orm.hibernate4.LocalSessionFactoryBean@46797063 转换为类型 org.hibernate.SessionFactory在 org.apache.aries.blueprint.container.AggregateConverter.convert(AggregateConverter.java:184)
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<bean class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" id="dataSource">
<property name="url"
value="jdbc:sqlserver://x:1433;DatabaseName=x" />
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="username" value="" />
<property name="password" value="" />
<property name="removeAbandoned" value="true" />
<property name="initialSize" value="20" />
<property name="maxActive" value="30" />
</bean>
<bean class="com.x.dto.ReferenceTable" id="refBean" />
<!-- <bean class="com.x.dao.ReferenceDAOImpl" id="MyBean">
<property name="sessionFactory" ref="mysessionFactory" />
</bean> -->
<!-- setup the Camel hibernate component -->
<bean class="org.apacheextras.camel.component.hibernate.HibernateComponent"
id="hibernate">
<property name="sessionFactory" ref="mysessionFactory" />
</bean>
<bean class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
id="mysessionFactory">
<property name="dataSource" ref="dataSource" />
<!-- here we define the hibernate mapping files we use -->
<property name="packagesToScan">
<list>
<value>com.x.dto</value>
</list>
</property>
<property name="annotatedClasses">
<list>
<value>com.x.dto.ReferenceTable</value>
</list>
</property>
<!-- and here we have additional hibernate options -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<camelContext id="_context1"
xmlns="http://camel.apache.org/schema/blueprint">
<route id="_route1">
<from id="from" uri="hibernate://com.x.dto.ReferenceTable?consumer.query=select x.data from com.x.dto.ReferenceTable x where x.id='id3'"/>
<!-- <bean id="_bean1" method="save(com.x.dto.ReferenceTable)" ref="MyBean"/>
<bean id="_bean2" method="getByID('id2')" ref="MyBean"/>
<convertBodyTo id="_convertBodyTo1" type="com.x.dto.ReferenceTable"/> -->
<to id="_to1" uri="log: ${body}"/>
</route>
</camelContext>
</blueprint>
Pom.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>camel-blueprint</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Camel Blueprint Quickstart</name>
<description>Empty Camel Blueprint Example</description>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<camel.version>2.17.0.redhat-630187</camel.version>
<version.maven-bundle-plugin>3.2.0</version.maven-bundle-plugin>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jboss.fuse.bom.version>6.3.0.redhat-187</jboss.fuse.bom.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.fuse.bom</groupId>
<artifactId>jboss-fuse-parent</artifactId>
<version>${jboss.fuse.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-blueprint</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<dependency>
<groupId>org.apache-extras.camel-extra</groupId>
<artifactId>camel-hibernate</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>fuse-public-repository</id>
<name>FuseSource Community Release Repository</name>
<url>https://repo.fusesource.com/nexus/content/groups/public</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>red-hat-ga-repository</id>
<name>Red Hat GA Repository</name>
<url>https://maven.repository.redhat.com/ga</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>fuse-public-repository</id>
<name>FuseSource Community Release Repository</name>
<url>https://repo.fusesource.com/nexus/content/groups/public</url>
</pluginRepository>
<pluginRepository>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>red-hat-ga-repository</id>
<name>Red Hat GA Repository</name>
<url>https://maven.repository.redhat.com/ga</url>
</pluginRepository>
</pluginRepositories>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${version.maven-bundle-plugin}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>keyvalue</Bundle-SymbolicName>
<Bundle-Name>Empty Camel Blueprint Example [keyvalue]</Bundle-Name>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>${camel.version}</version>
<configuration>
<useBlueprint>true</useBlueprint>
</configuration>
</plugin>
</plugins>
</build>
</project>