Gab
Gab

Reputation: 37

Spring boot webapp fail when deploing with AWS Elastic Beanstalk - jpa configuration?

I have a Spring web application that works fine locally. I have my MySQL database on Amazon RDS and I also store some images in an Amazon S3 bucket. I then tried to deploy the War using Elastic Beanstalk and when I enter the URL the only thing that I get is a 404 error.

I then went to look at the logs and I think that this is what is causing the problem:

javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution

So I assume that I have problems in my data source configuration, but I really can not find the solution.

This is my application.properties:

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.datasource.url = jdbc:mysql://mysql-instance.rrgatg5flqq6.us-east-2.rds.amazonaws.com:3306/mydb
spring.datasource.username = ****
spring.datasource.password = ****
spring.datasource.driver-class-name = com.mysql.jdbc.Driver

And this is the pom.xml:

<groupId>com.spring</groupId>
<artifactId>gabphoto</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<name>gabphoto</name>
<description>Exam project 5 sem</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.11.133</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Thank you in advance guys!

Upvotes: 1

Views: 891

Answers (1)

windupurnomo
windupurnomo

Reputation: 1190

I have experience same error like this using this technologi stack: elastic beanstalk - RDS - spring boot - postgresql.

This error can caused any problem, some of them, check RDS security group > Inboud > Edit > choose Anywhere in source column. Try this scenario, to ensure you can access database. May this help you...

RDS security group inbound > choose source anywhere

Upvotes: 3

Related Questions