Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7521991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:23:25+00:00 2026-05-30T02:23:25+00:00

In relation to my post/question EntityManager is always NULL using SpringFramework , I am

  • 0

In relation to my post/question “EntityManager is always NULL using SpringFramework”,
I am encountering the below exception on this portion of my code:

ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");

Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘tblFileinfoHome’: Injection of persistence fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;

Below are the files related to my Spring + Hibernate Project

<— persistence.xml —>

<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="msh" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>com.msh.TblFileinfo</class>
    </persistence-unit>
</persistence>

<— applicationContext.xml —>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:lang="http://www.springframework.org/schema/lang"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/lang
           http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
           http://www.springframework.org/schema/security">

    <!-- need to create database.properties file -->
    <context:property-placeholder location="classpath:database.properties"/>

    <context:component-scan base-package="com.msh"/>

    <!-- tell Spring that it should act on any @PersistenceContext and @Transactional annotations found in bean classes -->
    <!-- <tx:annotation-driven/> -->
    <tx:annotation-driven transaction-manager="transactionManager"/>

    <bean class="com.msh.TblFileinfoHome" />
    <bean class="com.msh.TblFileinfo" />
    <bean id="sample" class="com.msh.Sample" />

    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

    <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <!-- <property name="databasePlatform" value="${platform}" /> -->
        <property name="showSql" value="${database.showSql}" />
        <property name="generateDdl" value="${database.generateDdl}" />
    </bean>

    <bean id="entityManagerFactory" class="org.org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="msh" />
        <property name="dataSource" ref="dataSource" />
        <!-- <property name="loadTimeWeaver" class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /> -->
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>

    <bean  id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${database.driverClassName}" />
        <property name="url" value="${database.url}" />
        <property name="username" value="${database.username}" />
        <property name="password" value="${database.password}" />
    </bean>
</beans>

<— Main java code —>

package com.msh;

public class MavenSpringHibernate {

    /**
     * @param args
     */

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    Sample s = (Sample)appContext.getBean("sample");
    s.persist();ew Sample();
        s.persist();
    }
}

<— DAO —>

package com.msh;

import javax.ejb.Stateless;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Home object for domain model class TblFileinfo.
 * @see com.trendmicro.grid.mshPackage.TblFileinfo
 * @author Hibernate Tools
 */

/**
@Stateless
@Repository
@Transactional
*/

@Repository
public class TblFileinfoHome {

    private static final Log log = LogFactory.getLog(TblFileinfoHome.class);

    @PersistenceContext(unitName="msh")
    private EntityManager entityManager;

    @Transactional
    public void persist(TblFileinfo transientInstance) {
        log.debug("persisting TblFileinfo instance");
        try {
            entityManager.persist(transientInstance);
            log.debug("persist successful");
        }
        catch (RuntimeException re) {
            log.error("persist failed", re);
            throw re;
        }
    }

    @Transactional
    public void remove(TblFileinfo persistentInstance) {
        log.debug("removing TblFileinfo instance");
        try {
            entityManager.remove(persistentInstance);
            log.debug("remove successful");
        }
        catch (RuntimeException re) {
            log.error("remove failed", re);
            throw re;
        }
    }

    @Transactional
    public TblFileinfo merge(TblFileinfo detachedInstance) {
        log.debug("merging TblFileinfo instance");
        try {
            TblFileinfo result = entityManager.merge(detachedInstance);
            log.debug("merge successful");
            return result;
        }
        catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    @Transactional
    public TblFileinfo findById( Long id) {
        log.debug("getting TblFileinfo instance with id: " + id);
        try {
            TblFileinfo instance = entityManager.find(TblFileinfo.class, id);
            log.debug("get successful");
            return instance;
        }
        catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
}

— Entity —

package com.msh;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * TblFileinfo generated by hbm2java
 */
@Entity
@Table(name="tbl_fileinfo"
    ,catalog="behavior"
)
public class TblFileinfo  implements java.io.Serializable {


     private Long fileId;
     private String filename;
     private String filetype;

    public TblFileinfo() {
    }

    public TblFileinfo(String filename, String filetype) {
       this.filename = filename;
       this.filetype = filetype;
    }

     @Id @GeneratedValue(strategy=GenerationType.AUTO)


    @Column(name="file_id", unique=true, nullable=false)
    public Long getFileId() {
        return this.fileId;
    }

    public void setFileId(Long fileId) {
        this.fileId = fileId;
    }


    @Column(name="filename", length=200)
    public String getFilename() {
        return this.filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }


    @Column(name="filetype", length=50)
    public String getFiletype() {
        return this.filetype;
    }

    public void setFiletype(String filetype) {
        this.filetype = filetype;
    }
}

<— Sample class controller —>

package com.msh;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.trendmicro.grid.msh.TblFileinfo;
import com.trendmicro.grid.msh.TblFileinfoHome;


@Transactional
public class Sample {
    private TblFileinfo tinfo;
    @Autowired
    private TblFileinfoHome tinfoh;

    public Sample()
    {
        tinfo = new TblFileinfo("c:/jayson/murillo/pryde.exe", "uv_win32");
        //tinfoh = new TblFileinfoHome();
    }

    public void persist()
    {
        tinfoh.persist(tinfo);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:23:29+00:00Added an answer on May 30, 2026 at 2:23 am

    Seems like a library versions mismatch, thats why your getting AbstractMethodError when spring is calling SpringPersistenceUnitInfo see this question

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In relation to this question on Using OpenGL extensions , what's the purpose of
This question has some relation to this post I made recently: Drag a UIView
In relation to this post I'm using the MvcSiteMap provider. I can't seem to
There is an interesting post over here about this, in relation to cross-application flow
In relation to this stackoverflow question , how would I go about creating my
In relation to this question ( Efficient hashCode() implementation ) I have one more
This is in relation to this question I am hosting this WCF service in
First, sorry for the lengthy post. Basically, my question is this: I'm trying to
This is relation to my other post but it is a different scenario. When
In relation to another question , how do you account for paths that may

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.