Hi,

Please use hibernate 4.2.x latest release, it's OSGi friendly.
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋



On 2013-11-5, at 上午3:32, scottdawson wrote:

> Hello,
> I'm unable to get the Camel-JPA component working in ServiceMix 5.x. I'm
> using Hibernate with a Postgres database. I get a couple of different errors
> depending on the configuration. I'm building ServiceMix 5 using the latest
> source from Git.
> 
> If I use the Spring HibernateJpaVendorAdapter, I get the following error:
> org.apache.aries.blueprint.core - 1.1.0 | Unable to start blueprint
> container for bundle ...
> org.osgi.service.blueprint.container.ComponentDefinitionException: Error
> when instantiating bean hibernateJpaAdapter of class class
> org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
> ...
> Caused by: java.lang.NoClassDefFoundError:
> org/hibernate/ejb/HibernatePersistence
>        at
> org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.<init>(HibernateJpaVendorAdapter.java:57)
> 
> This is perplexing because I'm "wrapping" the Hibernate EntityManager
> library and I can see the missing class:
>> osgi:install -s wrap:mvn:org.hibernate/hibernate-entitymanager/3.6.0.Final
> Bundle ID: 187
>> osgi:classes 187
> wrap_mvn_org.hibernate_hibernate-entitymanager_3.6.0.Final (187)
> ...
> org/hibernate/ejb/HibernatePersistence.class
> ...
> 
> If I remove the JPA Adapter configuration and add this to the
> persistence.xml:
> <provider>org.hibernate.ejb.HibernatePersistence</provider>
> then I get this error:
> org.apache.aries.blueprint.core - 1.1.0 | Unable to start blueprint
> container for bundle ...
> org.osgi.service.blueprint.container.ComponentDefinitionException: Error
> setting property: PropertyDescriptor <name: entityManagerFactory, getter:
> class
> org.springframework.orm.jpa.JpaTransactionManager.getEntityManagerFactory(),
> setter: [class
> org.springframework.orm.jpa.JpaTransactionManager.setEntityManagerFactory(interface
> javax.persistence.EntityManagerFactory)]
> ...
> Caused by: java.lang.Exception: Unable to convert value
> org.springframework.orm.jpa.LocalContainerEn
> tityManagerFactoryBean@3f129523 to type
> javax.persistence.EntityManagerFactory
> 
> Here is my current configuration...
> Blueprint.xml:
> &lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;
>   xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
>   xsi:schemaLocation=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0
> 
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd&quot;>
> 
>   <bean id="transactionTemplate"
> class="org.springframework.transaction.support.TransactionTemplate">
>     <property name="transactionManager">
>       <bean class="org.springframework.orm.jpa.JpaTransactionManager">
>         <property name="entityManagerFactory" ref="entityManagerFactory"/>
>       </bean>
>     </property>
>   </bean>
> 
>   <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
>     <property name="entityManagerFactory" ref="entityManagerFactory"/>
>   </bean>
> 
>    <bean id="entityManagerFactory"
> class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
>      <property name="persistenceXmlLocation"
> value="classpath*:META-INF/persistence.xml"/>
>      <property name="persistenceUnitName" value="isdms" />
>      <property name="jpaVendorAdapter" ref="hibernateJpaAdapter" />
>    </bean>
> 
>    <bean id="hibernateJpaAdapter"
> class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
>    <property name="showSql" value="true" />
>    </bean>
> 
>   <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
>      <route>
>         <from
> uri="timer://foo?fixedRate=true&amp;period=5000&amp;repeatCount=10"/>
>         <from
> uri="jpa:com.acme.MyEntity?persistenceUnit=isdms&amp;consumeDelete=false"/>
>         <log message="Message body: ${body}"/>
>      </route>
>   </camelContext>
> </blueprint>
> 
> Persistence.xml:
> <persistence xmlns="http://java.sun.com/xml/ns/persistence";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="1.0">
>   <persistence-unit name="isdms" transaction-type="RESOURCE_LOCAL">
>      <provider>org.hibernate.ejb.HibernatePersistence</provider>
>      <properties>
> 
>         <property name="hibernate.dialect"
> value="org.hibernate.dialect.PostgreSQL82Dialect"/>
>         <property name="hibernate.connection.driver_class"
> value="org.postgresql.Driver"/>
>         <property name="hibernate.connection.url"
> value="jdbc:postgresql://..."/>
>         <property name="hibernate.connection.username" value="..."/>
>         <property name="hibernate.connection.password" value="..."/>
> 
> 
>      </properties>
>   </persistence-unit>
> </persistence>
> 
> Any help would be appreciated.
> 
> Thanks,
> Scott Dawson
> 
> 
> 
> 
> --
> View this message in context: 
> http://servicemix.396122.n5.nabble.com/Camel-JPA-with-Hibernate-tp5718305.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to