EasyMock Exception when calling createMock

I admit this is probably an obscure error, but I didn’t find anyone else talking about it. So, in an effort to help some other poor sap like me out…

If you receive this error in EasyMock 2.3

java.lang.NoSuchMethodError: org.easymock.internal.RecordState.(Lorg/easymock/internal/IMocksBehavior;)V
	at org.easymock.internal.MocksControl.reset(MocksControl.java:62)
	at org.easymock.internal.MocksControl.(MocksControl.java:26)
	at org.easymock.classextension.internal.MocksClassControl.(MocksClassControl.java:19)
	at org.easymock.classextension.EasyMock.createControl(EasyMock.java:108)
	at org.easymock.classextension.EasyMock.createMock(EasyMock.java:46)

It is most likely because you have an older version of EasyMock in your classpath. In my case a referencing eclipse project had it, and in my project “order and export” tab I had the Project Higher on the Export list than the new version of EasyMock. the easy way to fix this is just bump the newer EasyMock jars ahead of the older ones, or remove the older jars.

This entry was posted in programming, troubleshoot and tagged , , , . Bookmark the permalink.

2 Responses to EasyMock Exception when calling createMock

  1. Mattias says:

    Thanks! Fixed the problem for me :)

  2. Kevin says:

    Thank you, you’re a savior!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>