You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by kmohite <km...@cisco.com> on 2012/08/21 14:07:15 UTC

How to resolve dependencies related to hibernate in servicemix 4.4.2

I am not able to get the db operations working using hibernate in apache
servicemix. I am using oracle database and reading from the database table
in the camel-context route using hibernate. 

Actually when I run the camel-context locally from Fuse IDE, the db
operations work, but when I bundle the project and deploy it in servicemix I
am unable to resolve the dependencies related to hibernate.

Installing the project bundle into servicemix gives following dependency
errors related to hibernate:
1. Class not found - org/hibernate/ejb/HibernatePersistence 
   To fix this I installed hibernate-entitymanager-3.6.2.Final.jar, I
bundled the jar using bnd tool and then  installed it in servicemix. I also
put in this package under <Importe-Package> in bundle plugin in my project
pom.xml.  This resolved the dependency error .
2. Next error is Class not found - org/hibernate/MappingException
   For this I can install either hibernate-core-3.6.2.Final or
hibernate-3.6.2.Final ( aggregate jar).
   But when I install any of these jars the hibernate-entitymanager
installed in (1) above fails saying that it exports org.hibernate.engine
which is also exported by hibernate-core. 

How can I solve this error ? Actually most of the hibernate jars have
duplicate packages in them. 
   For e.g. 
   hibernate-core, hibernate and hibernate-entitymanager having
org.hibernate.engine.
   Also org.hibernate.annotations package is present in multiple jars. 

How can these jars co-exists in servicemix if I need to install all of them?
How can I get this dependency resolved ?

Following is my camel-context and spring bean configuration for reference
(EmployeeEntity mentioned below is the DB mapping class):   

/<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
	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">
    <route>
        <description>DB Test App</description>
        <from uri="jpa:test.demo.EmployeeEntity"/>
        <to uri="mock:result"/>
    </route>
    
  </camelContext>

	<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>

	<bean id="entityManagerFactory"
	
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceUnitName" value="camel" />
		<property name="jpaVendorAdapter" ref="jpaAdapter" />
	</bean>

	<bean id="jpaAdapter"
		class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
		<property name="databasePlatform"
value="org.hibernate.dialect.OracleDialect" />
	</bean>
</beans>/

Following is my 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="camel" transaction-type="RESOURCE_LOCAL">
		<class>test.demo.EmployeeEntity</class>
		<properties>
		    <property name="hibernate.connection.url"
value="jdbc:oracle:thin:@1.1.1.1:1521:MYDB" />
			<property name="hibernate.dialect"
value="org.hibernate.dialect.OracleDialect"/>
			<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
			<property name="hibernate.connection.username" value="USERNAME" />
			<property name="hibernate.connection.password" value="PASSWD" />
			<property name="hibernate.hbm2ddl.auto" value="update"/>
		</properties>
	</persistence-unit>
</persistence>
/


Thanks 
Kavita







--
View this message in context: http://servicemix.396122.n5.nabble.com/How-to-resolve-dependencies-related-to-hibernate-in-servicemix-4-4-2-tp5714210.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.