简体   繁体   中英

Spock framework throwing error while mocking a @component

I am using Spock with Spring and I am getting error while mocking one of my component class.

Please find the below stack trace. It has nothing more than this and I thus I am not able to proceed. Versions:

  • cglib-nodep : 3.2.0
  • cglib : 3.2.0
  • spock-core : 1.0-groovy-2.4
  • spring-test : 4.1.4.RELEASE

    java.lang.NoClassDefFoundError: Could not initialize class org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory$ConstructorFriendlyEnhancer at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(ProxyBasedMockFactory.java:80) at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:49) at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:51) at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44) at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:45) at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:281) at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:99) at TermsAndConditionsControllerAPISpec.setup(TermsAndConditionsControllerAPISpec.groovy:19)

Not sure why this happened but I just removed cglib and it just worked. So final dependency list was : cglib-nodep : 3.2.0 spock-core : 1.0-groovy-2.4 spring-test : 4.1.4.RELEASE

I am still not sure why this worked by removing cglib. In case someone has a detailed reason for this please share.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM