-
Notifications
You must be signed in to change notification settings - Fork 560
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
ApplicationContextException: Unable to start ServletWebServerApplicationContext #326
Comments
This is probably cause by the fact that we explicitly exclude the embedded Tomcat that implements To solve this, we could remove the exclusion from the dependency and simply shade Tomcat out when producing a build for AWS Lambda. Would that help? |
@boroda4436 I found the root cause and committed a fix in the |
Hi! I'm afraid I'm still having this problem even after the 1.5 release. I created a new project with:
Attempting to start the included |
The archetype by default excludes the embedded Tomcat since it is not useful in Lambda - this is why Spring can't find an implementation of ServletWebServerFactory. You can just uncomment the exclusion from the pom file: <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions-->
</dependency> Fair point though. I'll create a separate issue to track moving this into a profile for the next release |
It's true that removing that exclusion eliminates the exception, but the Spring Boot application still doesn't start up all the way; instead, it appears to hang shortly after displaying the Spring Boot banner. I think there may be something else at play. |
I was mistaken, and I apologize for the false alarm; I missed that the default logging level for the project is |
No worries. For the next release, we'll make sure to include the correct profiles in the archetypes. |
I'm using version 1.5 and still need to comment out the exclusions. Was 1.5 supposed to include a fix where we didn't have to comment that out? |
I'm using version 1.5. Getting this error. Could you please share some thoughts
this is how I am including the spring-boot-starter-web
|
Hi, I am still having this issue, could anyone take a look?
I change my dependency package like this
after many tries, I still couldn't make it work. |
Hmm we have working sample projects in https://github.com/awslabs/aws-serverless-java-container/tree/master/samples that you can use to compare. Or you'll share your non-working sample and we'll have a look? |
|
Well just remove the exclusion and then it will work. Just tried it and the sample was starting using Tomcat 9.0.50. |
I managed to recreate the issue. Since I am trying to integrate s3 into this project (as a starter code), so I click the "load Gradle project" and add the dependency into build.gradle. Then I try running the app it prompts this error. Also, I noticed the "edit configuration" window in idea prompts "Error: Module not specified". |
If you are using Gradle, you have to edit the Gradle file, not the Maven POM. I suggest to try the command line tools first (e.g. by just running mvn spring-boot:run) to avoid IDE issues. |
Scenario
Run the spring-boot2 app locally
Expected behavior
the app starts without exceptions
Actual behavior
error happens:
Steps to reproduce
Full log output
2020-02-26 15:57:01.303 INFO 59255 --- [ main] c.a.s.sample.springboot2.Application : Starting Application on Bogdans-MBP.mate.academy with PID 59255 (/Users/bchupika/IdeaProjects/Study/aws-serverless-java-container/samples/springboot2/pet-store/target/classes started by bchupika in /Users/bchupika/IdeaProjects/Study/aws-serverless-java-container)
2020-02-26 15:57:01.312 INFO 59255 --- [ main] c.a.s.sample.springboot2.Application : No active profile set, falling back to default profiles: default
2020-02-26 15:57:02.082 ERROR 59255 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
at com.amazonaws.serverless.sample.springboot2.Application.main(Application.java:47)
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:203)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153)
... 8 common frames omitted
Process finished with exit code 1
The text was updated successfully, but these errors were encountered: