Skip to content

Spring Boot 2.0.1 fails to start when web application uses spring-boot-starter-test #13047

Closed

Description

@beldenge

A Spring Boot 2.0.1 web application will not start if the spring-boot-starter-test dependency is included.

https://stackoverflow.com/questions/49917449/cannot-start-tomcat-server-when-having-spring-boot-starter-test-dependency-in/50157009#50157009

It seems to be related to the spring-core dependency within spring-boot-starter-test. If that specific dependency is excluded, then Spring Boot starts up fine.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Activity

  1. added
    status: waiting-for-triage
    on May 3, 2018
  2. wilkinsona commented on May 3, 2018

    @wilkinsona
    Member

    Thanks for the report, but it's not clear from the information provided what the problem might be.

    A test-scoped dependency should have no effect at all on the classpath when you run your application so I don't understand why the exclusion you've shown should make any difference. To help us diagnose the problem, can you please provide a minimal sample that reproduces the problem along with details of exactly how you're attempting to start the application.

  3. added
    status: waiting-for-feedback
    on May 3, 2018
  4. wanghongfei commented on May 4, 2018

    @wanghongfei

    +1, I have exact same issue.

  5. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on May 4, 2018
  6. added
    status: waiting-for-feedback
    and removed
    status: feedback-provided
    on May 4, 2018
  7. snicoll commented on May 4, 2018

    @snicoll
    Member

    @wanghongfei a +1 without a sample is not helping. I've created a sample project with web and test (removing the test scope for the latter) and the app starts just fine as @wilkinsona indicated above.

    If you want us to diagnose the problem you're experiencing, we need a sample that we can run ourselves.

  8. wanghongfei commented on May 4, 2018

    @wanghongfei

    hi, I created a demo project that is able to reproduce this issue:
    https://github.com/wanghongfei/springboot-issue-demo

    This application is unable to start unless you uncomment specific code snippet in pom.xml which excluding the spring-core dependency.

    Sorry about the last useless comment

  9. added
    status: feedback-provided
    and removed
    status: waiting-for-feedback
    on May 4, 2018
  10. wilkinsona commented on May 4, 2018

    @wilkinsona
    Member

    Thanks for the sample. This is a duplicate of #12457.

    You need to exclude commons-logging:common-logging which is currently being pulled in as a transitive dependency of org.hyperledger.fabric-sdk-java:fabric-sdk-java. You can do so by updating your pom like this:

    diff --git a/pom.xml b/pom.xml
    index 6fa205d..e9743e8 100644
    --- a/pom.xml
    +++ b/pom.xml
    @@ -36,6 +36,12 @@
                 <groupId>org.hyperledger.fabric-sdk-java</groupId>
                 <artifactId>fabric-sdk-java</artifactId>
                 <version>1.1.0-alpha</version>
    +            <exclusions>
    +                <exclusion>
    +                    <groupId>commons-logging</groupId>
    +                    <artifactId>commons-logging</artifactId>
    +                </exclusion>
    +            </exclusions>
             </dependency>
    
             <dependency>
  11. added
    status: duplicate
    for: external-project
    and removed
    status: feedback-provided
    status: waiting-for-triage
    on May 4, 2018
  12. snicoll commented on May 4, 2018

    @snicoll
    Member

    This application is unable to start

    For the record, it's starting just fine, you just don't get any console log for the reason @wilkinsona mentioned.

  13. wanghongfei commented on May 4, 2018

    @wanghongfei

    @snicoll Yes, I've noticed that. Thanks!

  14. beldenge commented on May 4, 2018

    @beldenge
    Author

    I believe my issue was also related to a transitive dependency on commons-logging, but it was slightly different as I am not using fabric-sdk-java. The curious part to me is why excluding a test-scoped dependency made it work in spite of the existence of commons-logging...

  15. wilkinsona commented on May 4, 2018

    @wilkinsona
    Member

    @beldenge My somewhat educated guess is that I was wrong when I said "a test-scoped dependency should have no effect at all on the classpath when you run your application " above and that the exclusion affected the ordering of the main class path. If you're sufficiently curious, you could verify that theory by comparing the classpath in the working and non-working cases.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectstatus: duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions