Setup web service using Amazon AWS and tomcat - java

I am pretty new to Amazon AWS technologies, and I have been going through all their documentation. My goal is to create a new web service for a use case (preferably REST) using Tomcat.
I want to use this service in multiple clients like Android, Iphone, Tablet, Web etc.
Some of the examples I want to support are like -
GET http://myservice.com/user/{userid}
PUT http://myservice.com/user/{user-data}
Does AWS or any other cloud service providers provide anything out of the box for deploying such services with minimal code changes?

With AWS, you create a virtual server, customize it, and then use it. When you create a server, you pick your operating system and the size of the server you need. Once it is running, you can login and customize it.
For example, you might start a linux server using the Amazon Linux AMI (amazon machine image). You can use yum to install tomcat. You can drop your war file into the tomcat webapps directory.
Set up access in the security group (firewall) to allow your clients to access the relevant port(s).
Bottom line is that the process is basically the same as if you are doing this on a new server of your own.

Related

What's the procedure of upload a java spring based web application to the real server, and how to use load balance to the server?

I am creating a simple web project with mysql database using Java Spring-MVC. Now I want to understand the full workflow of the web system development cycle.
How to upload a project to a real server?.
How to sync the database to a real server?.
How DC and DRC is sync with each other?.
Why and how to use "Load balancer" to the server?.
Apologize, if I said something non-technical.
I'll not go into too much details but here is the gist of it.
Before anything, the first thing to get sorted is the operating system of the server be it Linux, Windows Server and so on. The choice of operating system will depend on the constraints and requirements.
How to upload a project to a real server?
Any files which needs to be served should be hosted and served by a web application server such as Apache Tomcat, IIS, Websphere and many more.
The choice of web application server depends on a few things, such as the server operating system, the web application implementation and so on. For your case, which is a Spring MVC implemented in Java, you'll need to use a web application server that supports that, such as Apache Tomcat for example.
Once the choice is made, install the web application server on the server. After that, install your web application on the web application server.
How to sync the database to a real server?
I infer that you're referring about the connectivity between the Java web application to the database? Do comment if its not.
The Spring MVC web application can connect directly to the database via JDBC or JNDI (provided that the necessary configuration is configured on the web application server).
Of course, the database can be connected locally (if installed on the same server) or remotely.
How DC and DRC is sync with each other?
This is too broad to cover and the recovery strategy differs for every Data Center providers. But broadly, they employ redundancy and replication strategy to ensure the data is always backed up and available. Check with the providers individually for a better picture.
Why and how to use "Load balancer" to the server?
The load balancer primary purpose is to distribute the work load across multiple servers to achieve better TTFB. To do so, it sits in front of the servers and routes the request accordingly. Some of the load balancing solutions such as f5 explains about load balancing in greater detail.
Step 1: Install Application Server on your machine.
Step 2: Install JDK, Database server which are dependent on your application.
Step 3: Export your war from Eclipse/Netbeans
Step 4: Paste your war file on app server's deployment folder (webapps incase of tomcat)
Step 5: your application deployed

How to have Azure App Service Tomcat to forward all 80/443 traffic to JBoss running on the same App Service

First of all, my Azure subscription is through a Cloud Service Provider, so I don't have access to certain features (i.e. cannot install a marketplace tomcat, only the native one; with the native Tomcat I do not have access to server.xml, which I need for some traffic rerouting solutions - modifying Connectors).
The basic need is to have IBM's B2B Client app running and sending files back and forth. It comes with its own JBoss, and all you do is put the app in a directory on Azure App Service and run the executable. This is already not a problem, and I have it starting with the app service using a WebJob.
Problem:
App Service only has two inbound ports open - 80 and 443, and they are both being used by Tomcat.
So I need to either:
1) Disable Tomcat, and only have JBoss running and listening on those ports without conflicts;
or
2) Have native Tomcat forward traffic to JBoss.
How can I do either of those in this environment, and are there better solutions for this problem?
According to the subsection Network endpoint listening of the wiki page Azure Web App sandbox of Kudu for Azure App Services, you couldn't use the other ports on Azure App Service besides 80 & 443 to access the application server from the internet. So if you can't create a JBoss AS instance from Azure Marketplace, per my experience, I think the only way is that creating an Azure VM instance to install a JBoss AS instance to deploy your specified Java Application.
Hope it helps. Any concern, please feel free to let me know.

Amazon AWS WebApp with MongoDB

I have built a mobile application that needs to connect to my SpringBoot-WebApp which in turn has a MongoDB and some other things in the background.
I want to deploy this WebApp at Amazon AWS, but I am overwhelmed by all the possibilities. So far, I have just created it as a .jar, and ran it that way, and it worked fine at my other server.
Now, for traffic reasons and such, we want to move it to AWS. I have found out, that I need to create a .war instead of a .jar, which is not a problem. I then learned to upload this .war to Elastic Beanstalk. However, my application needs to connect to a MongoDB. I have logged on to AWS via SSH and installed MongoDB there and created the database, but it does not seem like this is the right way to do it.
It'd greatly appreciate if anyone could give me a hint on how to do this as I am very confused.
Thanks and best regards!
It isn't clear if you are doing this, but don't run MongoDB on Elastic Beanstalk. The Elastic Beanstalk server you have it installed on may be automatically deleted by AWS. In general you do not want to manually install anything on Elastic Beanstalk as it is a managed environment where servers may be automatically created or deleted based on server load.
Amazon doesn't provide a MongoDB service directly, so you either need to install and manage MongoDB on an EC2 instance (or fleet of instances) yourself, or use a third party MongoDB service that runs on AWS. You could use something like MongoLab which provides a MongoDB service that runs on AWS. This allows your network traffic between your web servers and database servers to stay within the AWS network, which you will want for both performance and security reasons.
If you use MongoLab just make sure you choose to create your database in the same AWS region that you are deploying your application to. Also, I wouldn't recommend their free sandbox databases for any sort of critical production application.
If you decide to install and manage MongoDB on AWS yourself, here is some documentation from Amazon, and some from MongoDB.

For J2EE project to run on different Computer what does it need?

I know for a Java Program to run on another Computer it needs JRE(Java Runtime Environment). But for a J2EE application (Serlvet-JSP) or Struts2 framework application or Hibernate framework application or any Framework application of Java what are need to Run it Successfully on another computer where it is not developed....
I know JRE is required for both type of Application. and JDK is for developing an application.
I also know that for Mobile application to run on device it needs an Emulator that supports the particular OS (Android, iOS, etc). Just like an Standalone Java Application.
But for running J2EE application is there any other requirements than JRE??
For Example:- I have made a site called SocialMash.com I want to have a working prototype to deliver to user (User meaning like we all use Stackoverflow and other sites). What will I require to configure the site.
I know I will require a server like Tomcat/JBOSS/GlassFish but that all will be on my side (server side/ development side) but Do the Users to use the site will require anything among JDK, JRE, Server, or anything to use SocialMash.com or just URL will be enough?????
You need to have a JavaEE application server. It runs on top of JRE. You can check this open-source reference implementation (full-profile, my favourite):
https://glassfish.java.net/
or if you want to have only web-profile:
http://tomcat.apache.org/download-80.cgi
Web profile is different from full profile in that web profile supports only Servlet-JSP, but not JPA (or hibernate as stated in your question).
Users will not require anything except for the browser in case you write a web application (Servlets+JSP, Struts, JSF, etc. - just give them a web reference). But you can go further than that. You can write a Java SE desktop client for EJB, or SOAP service (they will be placed in full-profile server like Glassfish), and distribute for your customers. In this way they will not require any browser, but your custom desktop program.
Some of the libraries require to be added to your application server and configured manually. Like Struts. In this case you first need to decide which framework/library you would like to use, then go to their web site, and follow the tutorial on its installation.
To host an J2EE application, a webserver is required that has servlet container. servers included in XAMPP/LAMP/WAMPP will do for php based application. But for J2EE application servlet container is rquired which is there in TOMCAT/GLASSFISH/JBOSS.
On the user side, the user sees pure HTML with additional js/css. He does not see the jsp scriplets/servlet code written in your J2EE application. so no java technology is required on the user system. He only needs a browser.
A J2EE project intends to create a web service. In order to run this project on your computer, you need a local server.
Any IDE can provide you a local server like Tomcat or Glassfish, you just need to try to run this project to get these options.
If you don't need to access the code on the other computer, two options:
You compile your project to get a .war file, which you can deploy on your Tomcat server, or any else.
You put this on a server of yours, and share the url.
Assuming that you are in charge of the app hosting:
If that the app is running on your own remote server, you just need to share the app url and your user can access it with his browser (nothing more is needed).
If you run it in your own computer, as localhost, he won't be able to access it, and I recommand the usage of a host like Openshift to make it accessible (that's a free solution).

Server to run java servlet

I'am developing a java servlet application, and tesing it on Eclipse + Apache Tomcat (refer: http://www.vogella.de/articles/EclipseWTP/article.html#overview_wtp).
The application is now tested on the localhost and accesed by any clients on the same LAN.
Now, I need to deploy it into the web server, where everyone from anywhere can access this servlet.
Coud you guide me the way that I've to do to archive this task.
You need to have a computer accessible to everyone - i.e. placed on the internet and not behind a firewall - with the appropriate software installed (and hardened against hacker attacks).
If you do not have such a computer, you can have a look at the Google Application Engine which allows you to deploy Java web applications (with some additional restrictions) to the Google cloud. This is free for low-volume applications.
Yes, you can do it by deploying your application in the Cloud Instance. Since we cannot able to make our server instance or computer to be run always(We may come across internet connection problems, Power Fluctuation, etc.,), We have lot of problems while making our instance public(In Security perspective too). So it is better to use cloud instances.
We have many Cloud Service Providers such as AWS by Amazon, Google Cloud, Microsoft Cloud, etc.,
Take a look on this List of Cloud Services Providers.(You have links for all top 10 providers)

Categories

Resources