读书人

EasyMock 错误

发布时间: 2012-10-18 13:46:55 作者: rapoo

EasyMock 异常
java.lang.NoSuchMethodError: org.easymock.internal.RecordState.(Lorg/easymock/internal/IMocksBehavior;)V
at org.easymock.internal.MocksControl.reset(MocksControl.java:66)
at org.easymock.internal.MocksControl.(MocksControl.java:29)
at org.easymock.classextension.internal.MocksClassControl.(MocksClassControl.java:19)

As a thumb rule…
Should you find any “L”s or “V”s in the exception stack trace, just check your CLASSPATH. There might be class files(jar files) conflict. Don’t just get bluffed by the Exception message: NoSuchMethodError. The Class and the method will be there…but it might be there more than ONCE.

I got this message while I was trying PowerMock. This distribution has its own EasyMock jar file and my project is also referencing an existing (old version) easy mock jar file. This was fixed when I reorderd the jar file in Order & Export tab of Eclipse’s Java Build Path.

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.


读书人网 >编程

热点推荐