1

I am trying to deploy a spring boot app into one EB worker tier but seems that EB it is not ready to manage this kind of project.

Have I to mandatory generate a .war from my spring boot app?

Thanks!

Antonio Acevedo
  • 1,480
  • 3
  • 21
  • 39

1 Answers1

5

I have found the problem.

EB expects a .war file and Spring Boot app usually is launche by a embedded Tomcat or Jetty.

I have found the solution in this guide:

http://spring.io/guides/gs/convert-jar-to-war/

Summing up:

  1. Add tomcat dependency with provided scope in pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    
  2. Create a class extending SpringBootServletInitializer and load the entrypoint within this class. This way, we are indicating to the servlet container how to launch the app.

    package com.proyecti.magma.conversionsworker.config.servlet;
    
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.context.web.SpringBootServletInitializer;
    
    import com.proyecti.magma.conversionsworker.entrypoint.Application;
    
    public class ServletConfig extends SpringBootServletInitializer
    {
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
    
    }
    
Antonio Acevedo
  • 1,480
  • 3
  • 21
  • 39
  • Hi did you try using Spring Boot + tomcat on ElasticBeanstalk with SSL? – Dimitri Nov 25 '14 at 15:59
  • Hi, sorry but I have not been dealing with SSL yet. Can this help you? http://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-servlet-containers.html#howto-configure-ssl – Antonio Acevedo Nov 25 '14 at 17:01
  • Could please share your instance configuration? Which Tomcat, which Java etc. Thanks! – Marek Jan 07 '15 at 11:15
  • Sorry but I am not working on that project now. I remember by heart that it was the default image provided using AWS wizard and customziations were related to install some required libraries using an initialization script inside a .ebextensions folder as well as enable websockets (this post can help you: http://stackoverflow.com/questions/18460832/websocket-with-tomcat-7-on-aws-elastic-beanstalk). Hope it helps! – Antonio Acevedo Jan 08 '15 at 20:39