Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mockito 2.1.0 throws IllegalAccessException #7888

Closed
delverdev opened this issue Jan 5, 2017 · 2 comments
Closed

Mockito 2.1.0 throws IllegalAccessException #7888

delverdev opened this issue Jan 5, 2017 · 2 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@delverdev
Copy link

I updated Mockito in my project to 2.1.0 and now all tests that use @SpyBean fail with the following StackTrace:

java.lang.IllegalAccessError: tried to access method org.mockito.internal.util.MockUtil.()V from class org.springframework.boot.test.mock.mockito.SpyDefinition

at org.springframework.boot.test.mock.mockito.SpyDefinition.(SpyDefinition.java:36)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parseSpyBeanAnnotation(DefinitionsParser.java:113)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parseElement(DefinitionsParser.java:81)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.access$000(DefinitionsParser.java:43)
at org.springframework.boot.test.mock.mockito.DefinitionsParser$1.doWith(DefinitionsParser.java:68)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:693)
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:673)
at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:63)
at org.springframework.boot.test.mock.mockito.MockitoContextCustomizerFactory.createContextCustomizer(MockitoContextCustomizerFactory.java:38)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.getContextCustomizers(AbstractTestContextBootstrapper.java:418)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:387)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildDefaultMergedContextConfiguration(AbstractTestContextBootstrapper.java:323)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildMergedContextConfiguration(AbstractTestContextBootstrapper.java:277)
at org.springframework.test.context.support.AbstractTestContextBootstrapper.buildTestContext(AbstractTestContextBootstrapper.java:112)
at org.springframework.boot.test.context.SpringBootTestContextBootstrapper.buildTestContext(SpringBootTestContextBootstrapper.java:78)
at org.springframework.test.context.TestContextManager.(TestContextManager.java:120)
at org.springframework.test.context.TestContextManager.(TestContextManager.java:105)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:152)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.(SpringJUnit4ClassRunner.java:143)
at org.springframework.test.context.junit4.SpringRunner.(SpringRunner.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

I also created an example that represents the error.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 5, 2017
@snicoll snicoll changed the title [spring-boot-test] Mockito 2.1.0 throws IllegalAccessException Mockito 2.1.0 throws IllegalAccessException Jan 5, 2017
@snicoll
Copy link
Member

snicoll commented Jan 5, 2017

Compatibility with Mockito 2 is available as of Spring Boot 1.5 (see #6520)

@snicoll snicoll closed this as completed Jan 5, 2017
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 5, 2017
@snicoll
Copy link
Member

snicoll commented Jan 5, 2017

Thanks for the sample btw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants