0

I have a Spring boot application which I am trying to deploy it on Tomcat server. When I run the application locally in eclipse, it successfully deployed. But when I try to deploy on the Linux tomcat server. It fails. I am not sure what is wrong with the configuration. I tried to place the war file under tomcat webapps folder and run the startup.bat file.But its keep on running with the log trace. Please suggest what should I try.

pom.xml

      <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.hc.medley</groupId>
<artifactId>MedleyBackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.3.RELEASE</version>
</parent>
<name>MedleyBackend</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <springframework.version>4.2.5.RELEASE</springframework.version>
    <hibernate.version>4.3.6.Final</hibernate.version>
    <jackson.version>2.5.3</jackson.version>

</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
     <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
    </dependency> 
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.7</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
         <artifactId>json</artifactId>
         <version>20180130</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        </dependency>
        <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.7.19</version>
       </dependency>

    <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
     <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>2.5</version>
    </dependency>
   <dependency>
     <groupId>org.apache.logging.log4j</groupId>
     <artifactId>log4j-jcl</artifactId>
     <version>2.5</version>
  </dependency> 
  </dependencies>
   <build>
    <plugins>
        <plugin><!-- Include if you want to make an executable jar[FAT JAR which 
                includes all dependencies along with sprinboot loader] that you can run on 
                commandline using java -jar NAME -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
         <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>

        <configuration>
            <source>1.8</source>
            <target>1.8</target>
          <executable>${JAVA_1_8_HOME}/bin/javac</executable>
        </configuration>
    </plugin>
    </plugins>
    <finalName>Medley</finalName>
</build>

Last few lines from server logs

       2018-02-27 19:25:29.736  INFO 14224 --- [localhost-startStop-1] c.m.medley.controller.Application        : Starting Application v1.0 on DC01SPBIAPPDV06 with PID 14224 (started by singhma1 in C:\apache-tomcat-8.5.27\apache-tomcat-8.5.27\bin)
         2018-02-27 19:25:29.751  INFO 14224 --- [localhost-startStop-1] c.m.medley.controller.Application        : No active profile set, falling back to default profiles: default
         2018-02-27 19:25:29.829  INFO 14224 --- [localhost-startStop-1] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@153860ce: startup date [Tue Feb 27 19:25:29 PST 2018]; root of context hierarchy
         2018-02-27 19:25:31.454  INFO 14224 --- [localhost-startStop-1] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$15e9d470] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
         2018-02-27 19:25:31.548  INFO 14224 --- [localhost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1719 ms
        2018-02-27 19:25:32.282  INFO 14224 --- [localhost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
       2018-02-27 19:25:32.282  INFO 14224 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'errorPageFilter' to: [/*]
        2018-02-27 19:25:32.282  INFO 14224 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
       2018-02-27 19:25:32.564  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.aimcare.medley.controller.IndexController.getIndexPage()
         2018-02-27 19:25:32.564  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/items/memberPage]}" onto public java.lang.String com.aimcare.medley.controller.MainTemplateController.getMemberPageTemplate()
         2018-02-27 19:25:32.564  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/items/editMemberPage]}" onto public java.lang.String com.aimcare.medley.controller.MainTemplateController.getMemberEditPageTemplate()
     2018-02-27 19:25:32.564  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/items/landingPage]}" onto public java.lang.String com.aimcare.medley.controller.MainTemplateController.getLandingPageTemplate()
      2018-02-27 19:25:32.564  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[GET],produces=[application/json]}" onto public java.util.List<com.aimcare.medley.model.Members> com.aimcare.medley.controller.SpringController.error() throws java.lang.Exception
       2018-02-27 19:25:32.579  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getMemberDetails/{memberId:.*}/{state:.*}],methods=[GET],produces=[application/json]}" onto public java.util.List<com.aimcare.medley.model.MedleyMemberDetail> com.aimcare.medley.controller.SpringController.getMemberDetails(java.lang.String,java.lang.String) throws java.lang.Exception
      2018-02-27 19:25:32.579  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getUserList],methods=[GET],produces=[application/json]}" onto public java.util.List<com.aimcare.medley.model.Members> com.aimcare.medley.controller.SpringController.getUserList() throws java.lang.Exception
     2018-02-27 19:25:32.579  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getUserbyState/{state:.*}],methods=[GET],produces=[application/json]}" onto public java.util.List<com.aimcare.medley.model.Members> com.aimcare.medley.controller.SpringController.getUserbyState(java.lang.String) throws java.lang.Exception
      2018-02-27 19:25:32.579  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addMemberContact],methods=[POST],produces=[application/json]}" onto public com.aimcare.medley.model.Member com.aimcare.medley.controller.SpringController.addMemberContact(com.aimcare.medley.model.Member)
      2018-02-27 19:25:32.579  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addMemberCallDetail],methods=[POST],produces=[application/json]}" onto public com.aimcare.medley.model.Member com.aimcare.medley.controller.SpringController.addMemberDetail(com.aimcare.medley.model.Member)
       2018-02-27 19:25:32.595  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
       2018-02-27 19:25:32.595  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
     2018-02-27 19:25:32.642  INFO 14224 --- [localhost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/static/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
     2018-02-27 19:25:32.736  INFO 14224 --- [localhost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@153860ce: startup date [Tue Feb 27 19:25:29 PST 2018]; root of context hierarchy
      2018-02-27 19:25:33.439  INFO 14224 --- [localhost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
       2018-02-27 19:25:33.454  INFO 14224 --- [localhost-startStop-1] c.m.medley.controller.Application        : Started Application in 4.781 seconds (JVM running for 8.579)
        2018-02-27 19:25:33.470  INFO 14224 --- [localhost-startStop-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@153860ce: startup date [Tue Feb 27 19:25:29 PST 2018]; root of context hierarchy
         2018-02-27 19:25:33.470  INFO 14224 --- [localhost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
MSV
  • 145
  • 1
  • 14

1 Answers1

0

To be able to create a deployable war file on top of what you already did;

1) Your main (Application class) should extend SpringBootServletInitializer and override the configure method as below:

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

2) In your pom file you should add a provided dependency to tomcat to prevent embedded container to interfere with the external one:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
</dependency>

Once these are added it should work fine.

FDirlikli
  • 185
  • 1
  • 4
  • After adding the above details mentioned by you. I am atleast seeing the Spring boot banner when I start the tomcat locally but I am still not able to deploy the war file through Tomcat Web Application Manager. Its giving me 404 error. Please suggest. – MSV Feb 23 '18 at 17:58
  • What version of Tomcat are you using? – FDirlikli Feb 23 '18 at 23:03
  • Apache Tomcat/8.5.27 – MSV Feb 23 '18 at 23:52
  • I posted the logs above too. I am not able to figure it out the issue. Is there any sample project you would recommend to try out? I tried some sample but that didn’t work as well. – MSV Feb 28 '18 at 14:06