Deploy Java Web Application + MongoDB on AWS - java

I have Java Web Application that runs on tomcat server, without any frameworks. My application works with MongoDB and I need to deploy it to AWS.
What are my steps need to be done?
Deploy war on Elastic Beanstalk?
Install Mongo on EC2?
What would be the process?
Actually, I don't understand how to use Mongo in AWS. Deploying war is simple but how to connect this project with my database?

MongoDB runs well in the cloud, both managed by yourself or through Atlas, the MongoDB-as-a-Service offering from MongoDB. The latter is probably the easiest way to get yourself started and may provide all the capability you require without having to take on management yourself.
https://www.mongodb.com/cloud/atlas
Disclosure: I used to work at MongoDB

Related

How do I migrate an existing tomcat application to AWS?

I am trying to migrate a tomcat application to AWS. Does it still mean I will be using tomcat on a AWS instance? What will be some of the challenges doing so?

How to go about creating a user authentication system for a Java web app on AWS Elastic Beanstalk?

I am trying to build a user authentication system for my Java web application, a basic inventory management system. I want to use AWS Cognito to keep track of all user information, and I am planning to deploy this app to Elastic Beanstalk, where it will also use some AWS database storage (DynamoDB or RDS, to be determined) to store the inventory data. This is my first Java web application so I am having a bit of a hard time understanding how the different technologies can work together.
After doing some research on building a user authentication system for a Java web app, it seems that Spring MVC would be a great framework to use as it would eliminate a lot of the grunt work with building a login system. However, pretty much every guide I have come across for a Spring MVC login system in Java requires Gradle or Maven. (I would be using Maven since I'm more familiar with it.) This is fine for when I'm running my project locally, but I'm concerned about how this will work when I want to upload my project to Elastic Beanstalk. It seems that the only way to deploy a a Java application from Maven to Elastic Beanstalk is with a open source project called Beanstalker, and I'm worried that if I develop my application using Spring MVC and Maven, when it comes time to put my project on Elastic Beanstalk I won't understand how to use this tool/it won't work properly.
So here are my main questions:
Would Spring MVC be a good tool to use in building my user authentication system? Is there a different framework I should look into?
Does using Spring MVC absolutely require the use of Gradle or Maven, or is there a way to build a user auth system with Spring MVC without it?
If I do use Spring MVC to build the auth system with Maven dependencies, will I have a hard time deploying it to Elastic Beanstalk, or am I overthinking it?
Thanks for any information, I greatly appreciate it.
Sure
Spring MVC does not require a specific dependency management tool
No more difficult than deploying any other Java app to EB
Note, you dont have to deploy using Maven just because you use Maven for dependency management. You would typically use the official Elastic Beanstalk command line tool to deploy your application.

How to install/run Spark Java Framework on AWS Elastic Beanstalk?

Normally, I build a Java web app using Tomcat or Glassfish into a WAR (web app archive file). This file can easily be deployed into AWS through Elastic Beanstalk with a few clicks. The integration is simple because Elastic Beanstalk allows us to deploy a web app on Tomcat/Glassfish/Java.
I recently started using a lightweight java framework called Spark, www.sparkjava.com . Is it possible to deploy this on Elastic Beanstalk in a few clicks? If not, is there an alternative to easily deploy a Spark Java web app onto AWS? Or, would I need to create an EC2 instance, copy the JAR app, and launch the JAR web app via command line?
Sure you can, either by deploying it as a war via the Tomcat platform, or run it as a fat jar via the Java SE platform.
I published an Archetype for AWS Elastic Beanstalk that uses DropWizard instead of Spark (but both use Jetty) - It should be pretty straightforward to adapt it to Spark. Note it uses the Docker Solution Stack (more flexible and easier to debug locally). This command should get you started:
$ mvn archetype:generate -Dfilter=elasticbeanstalk-docker
Also, AWS allows you to create a custom Java Application, like #k.liakos said in his answer.

How to upload Servlet/JSP website through Amazon Web Services?

I am working on a Servlet/JSP project and I want to host it on aws.amazon.com. I have already signed up for Amazon Web Services and after signing in this page opens up and I have no idea what to do or which option to select.
I think AWS provides a lot of customization with a lot advanced technical options to choose from, but this is difficult for beginners who just want to make their site running.
My project will use these:-
JSP/Servlets
CSS
MySQL
Struts2
Tomcat WebServer
I would suggest these approaches to study:
Elastic BeanStalk - This is AWS simply hosting model. If you're not IT savy you should pursue this approach
EC2 with MySQL RDS - In this case you'll create a Virtual Machine(s) (EC2) install Tomcat and other dependencies and deploy your app. You'll then use RDS to store your data (which is MySql as a service)
EC2 only - YOu'll do the same as 2. but install your own instance of MySql. There may be AMI's offered that you can provision that will meet your application requirements.
Other reading:
Route53 if your going to use AWS for your domain records
Elastic Load Balancing if your going to need High Availability
Elastic Block Store if you want persistent disks accross VMs
Network Security Groups to secure your VMs (for 1. and 2.)
Virtual Private Cloud for additional security
CloudFormation if you want to automate provisioning
There are many articles on: AWS Architecture
There is a eclipse plugin for Amazon web services.
The AWS Toolkit provides an AWS Java web project template for use in Eclipse. The template creates a web tools platform (WTP) dynamic web project that includes the AWS SDK for Java in the project's classpath. Your AWS account credentials and a simple index.jsp file are provided to help you get started. The following instructions assume you have installed both the Eclipse IDE for Java EE Developers and the AWS Toolkit plug-in. For more information, see Setting Up the AWS Toolkit for Eclipse.
Also check this & this
I would recommend 1st approach using Beanstalk to deploy your jsp application. There you are going to leverage all the advantages of AWS like load balancing, auto scaling, ddb and DW support and many other technologies. With Beanstalk you setup dev environment on your local machine and deploy the changes in AWS and once setup is done you are done...
May be you will need to spend some time on migrating from MySQL but that will be work on longer duration when you are going to have lot of users.

GWT in CloudFoundry will it work?

My web application is made with Java, specifically with the Google Web Toolkit (GWT). The back-end used
GWT RPC RemoteServiceServlet
Hibernate/Java
MongoDB (via Morphia)
and other Java libraries
I really did not use any Spring framework at all, will my web application be able to be deployed in a CloudFoundry MicroCloud and in CloudFoundry.com hosting?
Will I be needing to reconfiguring my web application that has been tested and deployed in a Tomcat Server with MySQL and MongoDB database?
GWT should not be an issue.
If you want to deploy a java web app not using Spring, you can deploy it as a java web app, then parse the VCAP_SERVICES manually to configure your data sources from the application.
See http://blog.springsource.org/2011/10/13/using-cloud-foundry-services-with-spring-part-1-the-basics/ for details
https://github.com/SpringSource/cloudfoundry-samples/tree/master/hello-java
Why wouldn't it work?
In the event it wouldn't, that wouldn't be because of GWT at least: GWT-RPC runs in AppEngine, so there's no reason it wouldn't work in CloudFoundry.

Categories