Org.hibernate.HibernateException: Unable to create default tuplizer instance [org.hibernate.tuple.entity.PojoEntityTuplizer]

I am developing a web application using the Hibernate framework. I got this error while trying to start webapp.

Error Console:

Exception caught in Create Account Dataorg.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] java.lang.NullPointerException 

My mapping file (hbm.xml):

 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="org.vgec.bean.CreateAccount" table="CreateAccount" > <id name="enrollment_number" type="java.lang.String"> <column name="enrollment_number" length="20"/> <generator class="assigned" /> </id> <property name="activation_code" type="java.lang.String"> <column name="activation_code" length="50"/> </property> </class> </hibernate-mapping> 

DataAccessObject File Code:

 public void addCreateAccount(CreateAccount act) throws Exception { Session session = null; try{ //this step will read hibernate.cfg.xml SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); session.save(act); tx.commit(); }catch(Exception e) { System.out.println("Exception caught in Create Account Data" + e); }finally{ session.flush(); session.close(); } } 

Here an exception is thrown in the above code - the line in catch is displayed in an error on the console.

Here is my bean or POJO file:

 package org.vgec.bean; public class CreateAccount { private String enrollment_number; private String activation_code; public String getEnrollment_number() { return enrollment_number; } public void setEnrollment_number(String enrollment_number) { this.enrollment_number = enrollment_number; } public String getActivation_code() { return activation_code; } public void setActivation_code(String activation_code) { this.activation_code = activation_code; } } 
  • I checked the solutions of other threads.
  • I have included javaassist.jar file
  • All installers and recipients have no typos.
  • I also have java.lang.NullPointerException .

What is the reason for this error?

+4
source share
2 answers

You must explicitly define a no-arg constructor. This is a requirement from Hibernate to all POJOs.

A detailed explanation can be found here: fooobar.com/questions/88353 / ...

+1
source

then you need to have a constructor without an argument, so it allows you to initiate an object with a controller, as well as a class of service, or in any case you use this object.

0
source

All Articles