Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot: Unable to start embedded Tomcat servlet container

I'm new to Spring Boot and having with error while running my application. I'm following a tutorial and I believe I'm having proper parent and dependencies with POM, please help me

main class:

package com.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration;  /**  * Hello world!  *  */  @SpringBootApplication public class App  {     public static void main( String[] args )     {         SpringApplication.run(App.class, "hello");     } } 

error is:

   org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat servlet container         at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:165) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]         at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:357) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.SpringApplication.run(SpringApplication.java:1124) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at org.springframework.boot.SpringApplication.run(SpringApplication.java:1113) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         at com.boot.App.main(App.java:18) [classes/:na]Caused by: java.lang.IllegalStateException: Tomcat connector in failed state         at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]         ... 10 common frames omitted 

POM :

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">       <modelVersion>4.0.0</modelVersion>    <groupId>com.boot</groupId>   <artifactId>das-boot</artifactId>   <version>0.0.1-SNAPSHOT</version>   <packaging>jar</packaging>     <parent>         <groupId>org.springframework.boot</groupId>         <artifactId>spring-boot-starter-parent</artifactId>         <version>1.3.1.RELEASE</version>     </parent>   <name>das-boot</name>   <url>http://maven.apache.org</url>    <properties>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>   </properties>    <dependencies>   <dependency>   <groupId>org.springframework.boot</groupId>   <artifactId>spring-boot-starter-web</artifactId>   </dependency>     <dependency>       <groupId>junit</groupId>       <artifactId>junit</artifactId>       <version>3.8.1</version>       <scope>test</scope>     </dependency>   </dependencies> </project> 
like image 793
amar Avatar asked Apr 24 '17 03:04

amar


People also ask

Does tomcat spring boot embedded container?

The Spring Boot starters ( spring-boot-starter-web in particular) use Tomcat as an embedded container by default.

Can we configure embedded tomcat server in spring boot?

We can start Spring boot applications in an embedded tomcat container that comes with some pre-configured default behavior via a properties file. In this post, we will learn to modify the default tomcat configurations via overriding respective properties in application.


2 Answers

Try to change the port number in application.yaml (or application.properties) to something else.

like image 141
Aziz Avatar answered Sep 22 '22 02:09

Aziz


You need to add the tomcat dependency in your pom

<dependency>         <groupId>org.springframework.boot</groupId>         <artifactId>spring-boot-starter-tomcat</artifactId> </dependency> 
like image 30
cralfaro Avatar answered Sep 21 '22 02:09

cralfaro