org.hibernate.HibernateException: Javassist Enhancement failed

[main] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
org.hibernate.HibernateException: Javassist Enhancement failed: entities.Employee
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:143)
    at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:634)
    at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3713)
    at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:360)
    at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
    at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
    at org.hibernate.impl.SessionImpl.load(SessionImpl.java:977)
    at org.hibernate.impl.SessionImpl.load(SessionImpl.java:970)
    at Operations.read(Operations.java:23)
    at Operations.main(Operations.java:50)
Caused by: java.lang.InstantiationException: entities.Employee_$$_javassist_0
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:140)
    ... 11 more
Exception in thread "main" org.hibernate.HibernateException: Javassist Enhancement failed: entities.Employee
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:143)
    at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:72)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:634)
    at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3713)
    at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:360)
    at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
    at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
    at org.hibernate.impl.SessionImpl.load(SessionImpl.java:977)
    at org.hibernate.impl.SessionImpl.load(SessionImpl.java:970)
    at Operations.read(Operations.java:23)
    at Operations.main(Operations.java:50)
Caused by: java.lang.InstantiationException: entities.Employee_$$_javassist_0
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:140)
    ... 11 more

This Exception is generated by Hibernate if no default constructor is avaible in entity class. here in entities.Employee class, the constructor Employee() must avaible in class.

1 comment:

Ashutosh said...

Add Default Constructor in POJO to avoid this exception.

Popular Posts