Created a spring boot REST application.
Run as Spring boot app
While running it as spring boot application
in eclipse. It's working great.
REST API are working with the URL - http://localhost:8080/schools
Deploy as WAR on tomcat
I followed the following steps
- Main class extends
SpringServletContainerInitializer
@SpringBootApplication
public class RmsBackendApplication extends SpringServletContainerInitializer {
public static void main(String[] args) {
SpringApplication.run(RmsBackendApplication.class, args);
}
}
- Added start class entry in
pom.xml
<properties>
<java.version>1.8</java.version>
<start-class>com.codingParkFun.rmsbackend.RmsBackendApplication</start-class>
</properties>
- Added starter tomcat dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Few documents say override
configure
method ofSpringServletContainerInitializer
. But in my caseSpringServletContainerInitializer
doesn't have aconfigure
method. I downloaded spring tools 4.0Generated package with
maven install
. War package is generated with the namerms-0.0.1-SNAPSHOT.war
Deployed the war package on the tomcat (version
9.0.27
)Accessing REST API URL -
http://localhost:8080/rms-0.0.1-SNAPSHOT/schools
- Tomcat localhost logs are as follow :
09-Nov-2019 11:13:31.013 INFO [main] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
09-Nov-2019 11:13:32.048 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
09-Nov-2019 11:13:32.048 INFO [main] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
09-Nov-2019 11:13:32.052 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@6231bb88')
09-Nov-2019 11:16:44.566 INFO [Thread-4] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed()
09-Nov-2019 11:16:44.566 INFO [Thread-4] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed()
09-Nov-2019 11:19:59.676 INFO [main] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
09-Nov-2019 11:20:12.722 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
09-Nov-2019 11:20:12.723 INFO [main] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
09-Nov-2019 11:20:12.728 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@2420e962')
09-Nov-2019 11:27:44.515 INFO [main] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
09-Nov-2019 11:27:45.490 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
09-Nov-2019 11:27:45.490 INFO [main] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
09-Nov-2019 11:27:45.494 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker@1c7da28')
09-Nov-2019 11:38:48.705 INFO [http-nio-8080-exec-7] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
Not sure while the application REST API is not working. Please guide.