Skip to content

SpringBootTest does not work with Java 10/modules [SPR-16976] #21514

Closed
@spring-projects-issues

Description

@spring-projects-issues
Collaborator

Keir Lawson opened SPR-16976 and commented

I attempted to port the Spring web testing example at https://github.com/spring-guides/gs-testing-web to Java 10 and modules, however I find when running my tests via Maven that the @SpringBootTest annotation is no longer able to locate my application class despite the code working previously before modularisation.I receive the following error when running mvn test

java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

Adding the application class explicitly as this message suggests then results in

java.lang.reflect.InaccessibleObjectException: Unable to make field private static java.lang.Object hello.Application$$EnhancerBySpringCGLIB$$d7dfca41.CGLIB$CALLBACK_FILTER accessible: module gs.testing.web does not "opens hello" to unnamed module @2fc6f97f

The changes I made to the initial repo can be viewed here: spring-guides/gs-testing-web@master...keirlawson:j10_modules


No further details from SPR-16976

Activity

spring-projects-issues

spring-projects-issues commented on Jun 26, 2018

@spring-projects-issues
CollaboratorAuthor

Juergen Hoeller commented

Please report this to the Spring Boot issue tracker on GitHub first: https://github.com/spring-projects/spring-boot/issues

There might be a core framework issue hiding here (which this JIRA instance is for) in which case I'm happy to reopen this JIRA ticket after the Boot team had a first pass.

spring-projects-issues

spring-projects-issues commented on Jun 26, 2018

@spring-projects-issues
CollaboratorAuthor

Keir Lawson commented

Have opened spring-projects/spring-boot#13581 as requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @jhoeller@spring-projects-issues

      Issue actions

        SpringBootTest does not work with Java 10/modules [SPR-16976] · Issue #21514 · spring-projects/spring-framework