VicTri
06.Февраль.2021 14:49:29
1
У меня возникла проблема с выполнением jar-файла, собранного в IntelliJ (v. 2020.3):
Oracle JDK 15.0.1 / Spring Boot 2.4.1
08:02:57.544 [main] ERROR org.springframework.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.
Open JDK 11 / Spring Boot 2.4.2
ERROR org.springframework.boot.SpringApplication - Application run failed java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
При этом запуск приложения из IntelliJ происходил нормально.
Проект создавался по материалам обучающего видео Мстислава Мартынюка: https://www.reunico.com/camunda-dlya-razrabotchika-chast-4.html
Комментарии Мстислава Мартынюка:
Касательно Вашей проблемы. Выглядит так, будто не удается запустить встроенный в Spring Boot сервер приложений Tomcat (возможно проблема в отсутствующих зависимостях или несовместимых версиях библиотек).
Проверьте:
Каким образом формировали проект? Через http://start.camunda.com или Spring Boot Initialzr?
Совпадают ли версии Camunda и Spring Boot. (На сайте Camunda есть страничка, описывающая совместимые версии Spring Boot и Camunda)
Проверьте, установлена ли аннотация @SpringBootApplication на main-классе.
Проект создавал через Spring Boot Initializr
Зависимости загружались для Camunda 7.14.0 (для нее как выяснилось нужно использовать Spring Boot 2.3.x.RELEASE: https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/version-compatibility/ )
Аннотация автоконфигурации и создания компонентов с внедрением зависимостей была установлена.
Также был подключен плагин spring-boot-maven-plugin в pom.xml
Настройки артефактов для jar-файла в структуре проекта в IntelliJ оставил по умолчанию.
Причина ошибки пока непонятна (тестировать с Spring Boot 2.3 не пробовал, т.к. на момент написания этого поста проблему уже решил, см. ниже). Судя по темам на форумах ошибка распространенная, при этом не одно из решений мне не помогло:
https://stackoverflow.com/questions/50231736/applicationcontextexception-unable-to-start-servletwebserverapplicationcontext
открытые 02:12PM - 26 Feb 20 UTC
закрытые 05:57PM - 08 Apr 20 UTC
enhancement
* Framework version: aws-cli/2.0.0dev4 Python/3.7.4 Darwin/19.2.0 botocore/2.0.0… dev3
* Implementations: Spring Boot
## Scenario
Run the spring-boot2 app locally
## Expected behavior
the app starts without exceptions
## Actual behavior
error happens:

## Steps to reproduce
1. Download the repo
2. cd samples/springboot2/pet-store
3. Run com.amazonaws.serverless.sample.springboot2.Application from your IDE as a simple spring-boot app.
## 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
…
РЕШЕНИЕ:
Сборку jar-файла сделал с помощью Maven на прямую, т.е. через командную строку: mvn package
при этом использовал apache-maven-3.6.3