Reputation: 87
The project is working fine on the VScode, but when I try to build as .jar and run in EC2 ubuntu instance or in my local, I am facing the following error message when I try to run by this command.
java -jar project-name.jar
13:54:04.899 [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.
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
at com.ndb.auction.AuctionApplication.main(AuctionApplication.java:21)
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:210)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
... 8 common frames omitted
@SpringBootApplication
@EnableScheduling
@EnableAutoConfiguration
public class AuctionApplication {
public static void main(String[] args) {
SpringApplication.run(AuctionApplication.class, args);
}
@Bean
GraphQLScalarType uploadScalarType() {
return ApolloScalars.Upload;
}
}
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AuctionApplication.class);
}
}
Upvotes: 0
Views: 3255
Reputation: 87
There is an issue with building jar in VScode, I tried Spring Tool Suite(spring-tool-suite-3.9.12.RELEASE-e4.15.0-win32-x86_64) to build jar file, and it is working now.
Upvotes: 1