0

I'm facing an AbstractMethodError when creating a simple Spring MVC application, running the following versions:

Hibernate - 5.4.2.Final Spring - 5.1.6.RELEASE Java - 11.0.9

I believe the problem is the way I'm wiring between my Repository, Service, and the Application Context.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/MyCVOnline/configuration/HibernateConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError

The entire code is in my GitHub https://github.com/Diego-Oviedo/JobBoardWithSpring

Any kind of help will be very appreciated

2 Answers2

0

It is really hard to guess bug with your log. Request you to update full log report so that we can answer in proper way.

Things which I observed with your log is given below:---

you should not pass "SessionFactory" as argument just remove n check whether working or not.

In your code:-----

@Bean
    @Autowired
    public HibernateTransactionManager transactionManager(SessionFactory s) {
         HibernateTransactionManager transactionManager
         = new HibernateTransactionManager();
       transactionManager.setSessionFactory(sessionFactory().getObject());
        return transactionManager;
    }

But it should be something like this:----

@Bean
        @Autowired
        public HibernateTransactionManager transactionManager() {
             HibernateTransactionManager transactionManager
             = new HibernateTransactionManager();
           transactionManager.setSessionFactory(sessionFactory().getObject());
            return transactionManager;
        }
priyranjan
  • 674
  • 6
  • 15
0

My problem was the Hibernate version I used; as I'm running Hibernate 5, several classes and dependencies are no longer supported such as org.jadira.usertype , joda-time, Query as a class, or SetString() as a method.

References:

Resolving java.lang.AbstractMethodError, Error creating bean with name 'entityManagerFactory' in Spring

Migrating To Hibernate 5 from 3

The following dependency was added,

        <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-java8</artifactId>
        <version>5.4.2.Final</version>
    </dependency>

I removed the org.jadira.usertype , joda-time dependencies from my pom.xml . However, my POJOS/Spring Beans were designed to consume those dependencies, i.e. with the @DateTimeFormat annotation

@Entity
@Table(name = "APPLICANTS_EDUCATION")
public class ApplicantEducation implements Serializable{


private static final long serialVersionUID = 1L;

@Column(name = "EDUCATION_TITLE")
private String educationTitle;

@Column(name = "SCHOOL_NAME")
private String schoolName;

@NotNull
@DateTimeFormat(pattern = "DD/MM/YYYY")
@Column(name = "START_DATE", nullable = false)
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
private String startDate;

The Annotation @Type and the object type were changed

@NotNull
@DateTimeFormat(pattern = "DD/MM/YYYY")
@Column(name = "START_DATE", nullable = false)
@Type(type = "org.hibernate.type.LocalDateTimeType")
private LocalDateTime startDate;

@DateTimeFormat(pattern = "DD/MM/YYYY")
@Column(name = "END_DATE")
@Type(type = "org.hibernate.type.LocalDateTimeType")
private LocalDateTime endDate;