[main] WARN GenericApplicationContext:591 – Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in class path resource : Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: net/bytebuddy/TypeCache

On upgrading Hibernate from version 3 to version 5, I got the above error.

Turned out that we were also using Mockito and it also has a dependency on byte buddy. So there was conflict of versions of byet buddy.

So here is fix:


exclude the byte-buddy jar from mockito.



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.