Hibernate buildSessionFactory() Exception

前端 未结 4 1871
一向
一向 2021-01-02 14:21

I have a serious problem with hibernate. I followed various books und online tutorials, but I ever get the same Exception \"ExceptionInInitializerError\" obviously thrown by

相关标签:
4条回答
  • 2021-01-02 14:38

    aused by: java.lang.NullPointerException at de.marcelstuht.nerven2.shared.model.Account.(Account.java:52) ... 49 more

    Remove anything from your constructor in Account. You have a circular dependency. And Hibernate uses the public no args consructor for its beans

    1. HibernateUtil loads
    2. That forces the static to run buildSessionFactory
    3. Hibernate instantiates Account via no args
    4. That in turn calls HibernateUtil.....

    Trust me: public no arg constructor with NO code, except POJO setters. Nothing else.

    0 讨论(0)
  • 2021-01-02 14:51

    I ran into this problem once before. I eventually discovered that adding a non-annotated method to the entity where annotations are decorating the getter methods, gets you in this situation. If you make the annotations around the fields rather than the getter methods, then you can have extra unmapped methods.

    0 讨论(0)
  • 2021-01-02 14:56

    Please check the javassist.X.X.jar is in your classpath.

    0 讨论(0)
  • 2021-01-02 14:58

    I too experienced the "Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister" and adding javassist.X.X.jar to the classpath took care of it.

    0 讨论(0)
提交回复
热议问题