Today I was working on a new project in which the persistence layer was based on Hibernate 3.6.3. Was using maven for managing the dependencies.
When I ran the code, I got the error, Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
...
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:77)
... 16 more
Caused by: java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilter
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 21 more
Solution is to add the maven dependency for javassist.
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.22.0-CR1</version>
</dependency>
I started thinking why does Hibernate need javassist. BTW javassist is a library which simplifies Java bytecode manipulation. But why does hibernate need to manipulate Java bytecode. Googled a bit and realized that, Hibernate uses proxies to intercept method invocation on entities to implement lazy loading. Lazy loading is loading objects from the database upon first access.
When I ran the code, I got the error, Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
...
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:77)
... 16 more
Caused by: java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilter
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 21 more
Solution is to add the maven dependency for javassist.
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.22.0-CR1</version>
</dependency>
I started thinking why does Hibernate need javassist. BTW javassist is a library which simplifies Java bytecode manipulation. But why does hibernate need to manipulate Java bytecode. Googled a bit and realized that, Hibernate uses proxies to intercept method invocation on entities to implement lazy loading. Lazy loading is loading objects from the database upon first access.
No comments:
Post a Comment