I am using Spring 3.1.1 in my application. I have integrated JPA and Hibernate 4.0.1 into it.
My entityManagerFactory and few more beans are not getting instantiated.
Code:java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V at org.hibernate.service.ServiceRegistryBuilder.buildServiceRegistry(ServiceRegistryBuilder.java:244) at org.hibernate.ejb.Ejb3Configuration.buildLifecycleControledServiceRegistry(Ejb3Configuration.java:930) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:903) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:268) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at ....(lines Deleted) Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [file:/C:/Users/User-1/MuleStudio/workspace/.mule/apps/eigSourceCode/appendContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/C:/Users/User-1/MuleStudio/workspace/.mule/apps/eigSourceCode/appendContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties (lines Deleted) Caused by: org.mule.api.config.ConfigurationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL ...(lines deleted) Caused by: org.mule.api.lifecycle.InitialisationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [file:/C:/Users/User-1/MuleStudio/workspace/.mule/apps/eigSourceCode/appendContext.xml]: Initialization of bean failed; nested exception ...(lines deleted) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL (lines deleted) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL (lines deleted) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ... 23 more Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.Environment.verifyProperties(Ljava/util/Map;)V at org.hibernate.service.ServiceRegistryBuilder.buildServiceRegistry(ServiceRegistryBuilder.java:244) (lines deleted) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 38 more
I am not supposed to use Maven, so i am adding jars directly to class path.
The Jars inside class path are:
ref library.JPG
Mule Studio Embedded Spring Jars
Spring jars.JPG
My persistance.xml is inside META-INF, and the code inside is:
The appendContext.xml is my application Context file used for configuring spring beans which contains the following code:Code:<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" 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_2_0.xsd"> <persistence-unit name="03offileLogger"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>com.comviva.mfs.eig.persistance.jpa.entities.TransactionLog</class> </persistence-unit> </persistence>
The errors pasted above are cut to fit the size, But after each error it is saying Invocation of init method failed;Code:xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <!-- scans the classpath for annotated components (including @Repostory and @Service that will be auto-registered as Spring beans --> <context:component-scan base-package="com.comviva.mfs.eig.logging.dataAccess, com.comviva.mfs.eig.logging.service" /> <!-- methods or classes needing to run in a complete transaction will be annotated with Transactional --> <tx:annotation-driven /> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/eigDB" /> <property name="username" value="root" /> <property name="password" value="tiger" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="persistenceUnitName" value="03offileLogger" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" /> <property name="showSql" value="true" /> <property name="generateDdl" value="true" /> </bean> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> </beans>
Initialization of bean failed;
I read it somewhere that there is some version conflict, so the entityManagerFactory is not being instantiated.
The code below shows my entity (only one table):
Please help me Resolve my Problem.Code:/** * The persistent class for the transaction_logs database table. * */ @Entity @Table(name="transaction_logs") public class TransactionLog implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name="TRANSACTION_ID") private Long transaction_id; @Column(name="INTERFACE_ID") private String interfaceId; @Column(name="FROM_ACCOUNT") private String from_account; @Column(name="SERVICE_TYPE") private String serviceType; @Column(name = "MSISDN") private String msisdn; @Column(name="TRANSACTION_TIME") private Timestamp transactionTime; @Column(name = "TRANSACTION_DATE") private Timestamp transactionDate; @Column(name="FROM_ACCOUNT_TYPE") private Integer fromAccountType; @Column(name="TRANSMISSION_DATE_TIME") private Timestamp transmissionDateTime; @Column(name="INTERFACE_TXN_ID") private Long interfaceTxnId; @Column(name="AVILABLE_BALANCE") private Double avilableBalance; @Column(name="TOTAL_BALANCE") private Double totalBalance; @Column(name="TXN_STATUS") private String txnStatus; @Column(name="MESSAGE") private String message; public TransactionLog() { } (followed by setters and getters) }


Reply With Quote
