Spring Boot Application immediately shuts down after starting in external TOMCAT


Spring Boot Application immediately shuts down after starting in external TOMCAT



Spring boot immediately shuts down after starting in external TOMCAT. But in Eclipse this runs well and JAR with embed too.



I use Tomcat 7 and JAVA 8.
I read a lot of webs and documentation which do not exist.



My Eclipse POM is:




http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0


<groupId>com.suez.demo</groupId>
<artifactId>Myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>Myappname</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>com.suez.demo.SuezApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.notnoop.apns</groupId>
<artifactId>apns</artifactId>
<version>1.0.0.Beta6</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>com.suez.demo.ws</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
</configuration>
</plugin>

</plugins>
</build>





Tomcat output log last lines are:


2018-06-29 10:27:37.874 INFO 640 --- [ost-startStop-3] com.suez.demo.SuezApplication : Started SuezApplication in 29.104 seconds (JVM running for 91.714)
2018-06-29 10:27:37.905 INFO 640 --- [ost-startStop-3] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@75e8c829: startup date [Fri Jun 29 10:27:11 CEST 2018]; root of context hierarchy
2018-06-29 10:27:37.936 INFO 640 --- [ost-startStop-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-06-29 10:27:37.952 INFO 640 --- [ost-startStop-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'



Can someone help me please?





Try to run tomcat by command line to get any error outputs not reported in logs.
– Tobia
Jun 29 at 11:13





if you want to run with external tomcat, you should remove dependency of embedded tomcat and exclude it from spring boot.
– amir110
yesterday




1 Answer
1



It's hard to say out of the information you've provided, but what looks suspicious to me is that you're using spring-boot-starter-web which in turn brings tomcat starter transitively.



I see that the packaging of this module is WAR, so its intended to run in an external web container, but on the other hand, you say that it runs fine in "JAR with embed too".
So it's a little bit confusing.



I've never by myself deployed spring boot application as a WAR file, but I believe you can go to Start.spring.io and generate a sample application that will package itself into WAR. This option is not shown by default, so you'll have to click on "switch to the full version" link





Hi @Mark, thanks for answer. For deploy JAR I change WAR to JAR in POM and delete 'provided' from spring-boot-starter-tomcat as tell in oficial docs of spring boot deployment WAR. I have do a lot of tryies without success, included redo the project and omite spring-boot-starter-web dependence.
– user1861554
Jun 29 at 11:04





Tomcat error logs from war: Jun 29, 2018 1:14:45 PM org.apache.catalina.core.StandardContext startInternal SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file Jun 29, 2018 1:14:45 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/Suez-0.0.1-SNAPSHOT] startup failed due to previous errors.
– user1861554
Jun 29 at 11:16





I think in the war you somehow end up with tomcat related jars. ( just open up a war and check what's in WEB-INF/lib there. if you see tomcat stuff it's bad, because these classes can clash between container classes and your applications classes. I think that when you'll check an example application from start.spring.io you won't find any tomcat related stuff in the war
– Mark Bramnik
Jun 29 at 15:22





of course to track the jars you can use mvn dependency:tree command, but it's a different story :)
– Mark Bramnik
Jun 29 at 15:22






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV