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

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

Closed
beldenge opened this issue May 3, 2018 · 9 comments
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@beldenge
Copy link

beldenge commented May 3, 2018

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>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 3, 2018
@wilkinsona
Copy link
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.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label May 3, 2018
@wanghongfei
Copy link

+1, I have exact same issue.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 4, 2018
@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels May 4, 2018
@snicoll
Copy link
Member

snicoll commented May 4, 2018

@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.

@wanghongfei
Copy link

wanghongfei commented May 4, 2018

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

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 4, 2018
@wilkinsona
Copy link
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>

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels May 4, 2018
@snicoll
Copy link
Member

snicoll commented May 4, 2018

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.

@wanghongfei
Copy link

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

@beldenge
Copy link
Author

beldenge commented May 4, 2018

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...

@wilkinsona
Copy link
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
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

5 participants