Java – Class Mocking Requires to Have cglib and objenesis libraries in the classpath – Solved

Class Mocking Requires to Have cglib and objenesis Libraries in the classpath – Solved

In java when you are trying to test easymock-ed classes, you will most likely get this the following annoying error message: class mocking required to have cglib and objenesis libraries in the classpath

Solution:

1. Download the cglib library from here: https://mvnrepository.com/artifact/org.glassfish.hk2.external/cglib/2.1.3

2. Download the objenesis library from here: https://mvnrepository.com/artifact/org.objenesis/objenesis/2.5

3. in Eclipse, right click on the directory in which your test classes reside, and go into Properties

4. Navigate to Java Build Path -> and select the Libraries tab

5. Click the Add External Jars button and point to the objenesis_xx.jar and cglib_xxxx. jar files

 

 

Leave a Reply