Hosting spring boot app

0 votes

I could not host my spring boot app to Amazon Web Services: Elastic Beanstalk. I did follow some video tutorials and stack overflow posts. still helpless. I want to host my war file to AWS and run it successfully. Here is my pom.xml and other stuff. it works well in the local. but after deploying to aws it does not work. the health status shown is severe.

Error Page Screenshot

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.cloudsofts.cloudschool</groupId>
    <artifactId>CloudSchool</artifactId>
    <version>1.0.0</version>
    <name>Cloud School</name>
    <description>School Management Software</description>


    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.7.0</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

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

    </dependencies>

</project>

New Error

------------------------------------
/var/log/nginx/error.log
-------------------------------------
2018/03/27 15:41:56 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:41:56 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:05 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:06 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:15 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:16 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:25 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:26 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:35 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:36 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:45 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:46 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:55 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:42:56 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:43:05 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:43:06 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:43:15 [error] 29286#0: *22 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.29.42, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"
2018/03/27 15:43:16 [error] 29286#0: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.11.79, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "172.31.2.252"

Sep 11, 2018 in AWS by bug_seeker
• 15,510 points
2,483 views

1 answer to this question.

0 votes

There are a couple of things wrong in your pom.xml

  1. mixing version of Spring Boot 1.5.2 and 1.5.9 (never mix versions of a framework).
  2. Inclusion JPA 1.0 API whereas you use a JPA 2.0 provider
  3. Generally AWS BeanStalk want your app to run on port 5000.

For 1 remove the <version> tag in your conflicting dependency and/or change the version of Spring Boot to the matching version.

Remove the JPA 1.0 API.

AWS expects your application to run on port 5000. Either specify this in the application.properties to be the port or specify a environment variable SERVER_PORT with value 5000 in your AWS environment. See Deploying a Spring Boot Application on AWS and especially the section on how to specify the port.

Get your Spring Certification today to become certified.

answered Sep 11, 2018 by Priyaj
• 58,020 points

Related Questions In AWS

0 votes
1 answer

S3 Static Website Hosting Route All Paths to Index.html

Yes there is an easy way to ...READ MORE

answered Apr 8, 2018 in AWS by code_ninja
• 6,300 points
3,439 views
0 votes
1 answer

Which cloud hosting is best ( AWS or Azure or Google)

Hello @Hammer, This totally depends on your needs, ...READ MORE

answered Aug 10, 2018 in AWS by Priyaj
• 58,020 points
951 views
0 votes
1 answer

Web Hosting on Amazon AWS (PHP + MySQL)

You can simply refer the following link, ...READ MORE

answered Aug 7, 2018 in AWS by Priyaj
• 58,020 points
1,181 views
+1 vote
2 answers
0 votes
1 answer

Validate a jwt token from cognito

Here is a documentation on how to ...READ MORE

answered Oct 31, 2018 in AWS by Priyaj
• 58,020 points
4,000 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to deploy Spring Boot RESTful Web Service Docker img to EC2?

Typically I run application on separate port ...READ MORE

answered Sep 7, 2018 in AWS by Priyaj
• 58,020 points
2,680 views
+3 votes
3 answers

Terraform AWS Cognito App Client

This feature is not currently supported by ...READ MORE

answered Aug 28, 2018 in AWS by eatcodesleeprepeat
• 4,710 points
3,620 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP