Announcement Announcement Module
Collapse
No announcement yet.
JPA 2.0 & Hibernate 4.0.1 & Spring 3.1.1 Compatibility Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA 2.0 & Hibernate 4.0.1 & Spring 3.1.1 Compatibility

    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:
    Attachment

    Mule Studio Embedded Spring Jars
    Attachment

    My persistance.xml is inside META-INF, and the code inside is:

    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 appendContext.xml is my application Context file used for configuring spring beans which contains the following code:

    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>
    The errors pasted above are cut to fit the size, But after each error it is saying Invocation of init method failed;
    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):

    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)
    
    }
    Please help me Resolve my Problem.
    Attached Files
    Last edited by bali208; Oct 10th, 2012, 04:19 AM. Reason: To add pics of jar files

  • #2
    I suggest you check your classpath... Make sure that you use the correct hibernate versions and that there isn't another one in your classpath also make sure that there isn't another hibernate jar somewhere else on yuor server.

    Why on earth aren't you supposed to use maven?! What kind of org. you are in basically that sets you back about 10 years...

    Comment


    • #3
      I have checked everywhere,
      I am running a standalone project so question of server.
      Only the jar files i have pasted as a jpg files in the thread are the only jars i am using.

      I checked my class path, and it does contains only required jars.
      Plez view the jpg files (picture of my jars in my project)
      and let me know if i have to remove any.

      hehehe, We are going to use maven in the next stage, this is the initial stage of experimenting with mule studio.

      please help me resolve this issue.

      Thank you Marten.

      Originally posted by Marten Deinum View Post
      I suggest you check your classpath... Make sure that you use the correct hibernate versions and that there isn't another one in your classpath also make sure that there isn't another hibernate jar somewhere else on yuor server.

      Why on earth aren't you supposed to use maven?! What kind of org. you are in basically that sets you back about 10 years...

      Comment


      • #4
        Trust me there is, as mentioned before, somewhere either an old jar or the same jar in a different classloader...

        Also starting a project without maven and trying to shoehorn it in later is IMHO stupid, start with maven (or gradle or ant+ivy or) but don't try to retrofit it later on...

        Comment

        Working...
        X