Announcement Announcement Module
Collapse
No announcement yet.
Spring-JPA-Hibernate configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-JPA-Hibernate configuration

    I'm using JBoss 4.2 with the default Hibernate 3 and Spring 2. I'm getting the following error:

    Code:
    17:08:36,119 INFO  [Configuration] Reading mappings from resource : META-INF/orm.xml
    17:08:36,119 INFO  [Ejb3Configuration] [PersistenceUnit: hibernate-jpa] no META-INF/orm.xml found
    17:08:36,149 INFO  [DefaultListableBeanFactory] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@110d68a: defining beans [dataSource,entityManagerFactory,daoFactory,baseService,ManageMemberService,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor,sqlMapClient,sqlMapClientTemplate,memberDao,memberJPADao]; root of factory hierarchy
    17:08:36,149 ERROR [STDERR] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [com/companyName/membership/config/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
    17:08:36,179 ERROR [STDERR] Caused by: 
    17:08:36,179 ERROR [STDERR] java.lang.ExceptionInInitializerError
    Here's my "applicationContext.xml":

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans default-lazy-init="false" default-autowire="no" default-dependency-check="none">	
    	
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="java:EJB3MySQL"/>	
    		<!-- <property name="jndiName" value="OraclePOC"/>  -->
    		<!-- <property name="jndiName" value="OraclePOC10g"/>  -->
    	</bean>
    
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceXmlLocation" value="com/companyName/membership/config/jpa/persistence.xml"/>
    		<property name="persistenceUnitName" value="hibernate-jpa"/>
    		<property name="dataSource" ref="dataSource"/>		
    		<property name="loadTimeWeaver">
    			<bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
    		</property>
    		<!-- 
    		<property name="jpaVendorAdapter">
    			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<property name="showSql" value="true"/>
    				<property name="generateDdl" value="true"/>
    				<property name="databasePlatform" value="org.hibernate.dialect.MySQLInnoDBDialect"/>				
    			</bean>
    		</property>
    		 -->	
    	</bean>
    	
    	<!-- define the DAO factory bean which holds references to all DAOs -->
    	<bean id="daoFactory" class="com.companyName.framework.dao.DaoFactory">
    		<!--  this is where we'll declare all DAOs stored as a Map -->
    		<property name="daos">
    			<map>
    				<entry key="com.companyName.domain.Member">
    					<ref bean="memberJPADao"/>
    				</entry>
    			</map>
    		</property>		
    	</bean>	
    	
    	<!-- define the "service" beans -->
    	<bean id="baseService" class="com.companyName.framework.service.BaseService">
    		<property name="daoFactory" ref="daoFactory"></property>		
    	</bean>
    	<bean id="ManageMemberService" 
    		class="com.companyName.membership.service.ManageMemberService"
    		parent="baseService">
    	</bean>	
    
    	<!-- Spring JPA support -->
    	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
    	
    	<!-- ========================= DAO DEFINITIONS: IBATIS IMPLEMENTATIONS ========================= -->
    	<!-- SqlMap setup for iBATIS Database Layer -->
    	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    		<property name="configLocation" value="com/companyName/membership/config/ibatis/SqlMapConfig.xml"/>		
    		<property name="dataSource" ref="dataSource"/>
    	</bean>
    
    	<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
    		<property name="sqlMapClient" ref="sqlMapClient"/>
    	</bean>
    	
    	<!-- IBATIS DAOs -->	
        <bean id="memberDao" class="com.companyName.membership.dao.ibatis.MemberIBatisDao">
    		<property name="sqlMapClientTemplate" ref="sqlMapClientTemplate"/>
    	</bean>
    
    	<!-- ========================= DAO DEFINITIONS: JPA IMPLEMENTATIONS ========================= -->
    	<!-- JPA DAOs -->
        <bean id="memberJPADao" class="com.companyName.membership.dao.jpa.MemberJPADao" />
    		
    </beans>
    And here's my "persistence.xml" file:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
        version="1.0">
    
    	<persistence-unit name="hibernate-jpa" transaction-type="JTA">
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<properties>
    			<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
    			<!-- <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/> -->
    			<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>			
    		</properties>
    	</persistence-unit>						
    	
    	<persistence-unit name="toplink-jpa" transaction-type="JTA">
    		<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    		<properties>
    			<property name="toplink.ddl-generation" value="drop-and-create-tables"/>
    			<property name="toplink.create-ddl-jdbc-file-name" value="toplink-create.sql"/>
    			<property name="toplink.drop-ddl-jdbc-file-name" value="toplink-drop.sql"/>			
    			<property name="toplink.logging.level" value="FINE"/>						
    			<property name="toplink.platform.class.name" value="oracle.toplink.essentials.platform.database.MySQL4Platform"/>									
    		</properties>
    	</persistence-unit>						
    	
    </persistence>
    Obviously, I don't have any orm.xml file since I'm trying to use the Java 5 annotations. Somehow, Hibernate is still trying to find mapping files (old way) and I don't know what's needed to make use of annotations.

    Is is something wrong with my configuration files above or am I missing something completely (again this is deployed and should run within JBoss 4.2) ?

    Thanks.
Working...
X