Enrique GF
Enrique GF

Reputation: 1295

After deployed the App in Elastic Beanstalk end point of app throws 404 not found in SpringBoot+MySql+Angular app with maven

is literally my first time on AWS deployments , and doing it by myself is harder the task. After having created my app in Elastic Beans and its respective RDS database with its instance , i created a Snapshot (jar) on my Springboot app which was also implemented in the deployment process of the AWS application. Also several items were configured in its Software Category referring the RDS database endpoint, server ports, user-name of database , etc... enter image description here.

Then after all that process , got the app deployed with a url. But when i apply that url with the endpoints my springboot controllers have , i receive as error a 404 Not Found; but if i decide to work on local requesting only the RDS database created by the application in Elastic Bean the endpoints shows data and the app works

Literally on my Spring Boot App i declared in the app. properties the connection to that database in AWS

spring.datasource.url=jdbc:mysql://aat54g98qswmf3.clnhc7kmwszz.us-west-2.rds.amazonaws.com:3306/ebdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

spring.datasource.username=root
spring.datasource.password=xxxx
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

logging.level.org.hibernate.SQL=debug

thus my controllers in the spring working in local don't have any problem


@RequestMapping(path = "/restaurant-booking/version1")
public class RestaurantController {

    @Autowired

    RestaurantService restaurantService;

    @ResponseStatus(HttpStatus.OK)
    @RequestMapping(value = "/restaurant/all", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    some code.........
    };

then on my browser: enter image description here

But if i switch to the url facilitated by the deployed EB app in AWS, and the use the same endpoint

enter image description here

Any help guys would be amazing , cause honestly can't find the problem or where to look at! Thanks in advance!!!

Upvotes: 0

Views: 722

Answers (2)

Cyber_wolf
Cyber_wolf

Reputation: 44

The problem might be arising due to the connectivity with the RDS and the correct Environment configuration for your Spring Boot Application.

I would suggest that prior to continuing with the environment creation (or even after), make sure you connect the RDS properly. For the configuration part:- you can make use of application-prod.properties file and specify an environment variable and value for software configuration labelled SPRING_PROFILES_ACTIVE and set its value to prod.

The application-prod properties consist of:-

server.port=5000 
spring.datasource.url=jdbc:mysql://${RDS_HOSTNAME}:${RDS_PORT}/${RDS_DB_NAME} 
spring.datasource.username=${RDS_USERNAME}
spring.datasource.password=${RDS_PASSWORD}
spring.jpa.hibernate.ddl-auto=create

Select a suitable RDS before or after creating the environment.

You need to configure the inbound and outbound rules for security group encompassing the RDS manually to allow access for creating, delete, update, etc.

And then finally upload the jar file in the environment. Worked for me.

Upvotes: 0

Deadron
Deadron

Reputation: 5289

The whitelabel error page is the default error page in spring when you have not defined your own. This means your application is deployed and running. You either messed up your request mapping or your url.

If we look at your mappings we see the url should be .../restaurant-booking/version1/restaurant/all

Request mappings get nested when they are on the class and method level.

You actually used the correct url locally but not on your deployed version.

Upvotes: 1

Related Questions