How to configure Glassfish on AWS Elastic Beanstalk, Connection Pool and Realm - java

I developed a Java EE 7 application, that uses Glassfish as the application server and MySQL as the database.
locally every thing is working correctly
now, I want to deploy the application to the cloud using AWS.
after reading some official documentations:
I created The database in the cloud 'AWS RDS', and conneted to it from MySQL Workbench and also The application in my workspace was able to connect to it and act on it.
Now for The application deployment I used Elastic Beanstalk with Glassfish 4.1 Java 8 (the docker one).
The probleme is that I need to configure Glassfish In AWS to
Create JDBC Connection Pool
Create JDBC Resource
Create A Security Realm
so that the apllication can work correctly.
How Can I do This?

I switch to Jelastic, I can access admin page usign their cloud, and I already deployed my appication

Related

Is it possible to run a Java EE backend with persistent H2 in EC2?

I want to run an Java EE application which uses Hibernate and a H2 database in the cloud, e.g. in EC2. The application offers a REST interface and modifys the (currently in local develop mode) in memory H2 database.
Is it possible to deploy the application in EC2 (e.g. with Tomcat server) with a H2 database in file mode, so that the database will not reset during restart of the server and persist the data?

Deploy Java Web Application + MongoDB on AWS

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

REST API AWS cloud using java

I am new to AWS , want to develop a cloud ready java application REST API.
The application will hit the MySQL database and produce output as JSON after querying the database.
IP:port/application?q=<query> response is JSON.
How to achieve it ? the data in MySQL is mostly static 100MB data but used very frequently.
It is very straight forward. if you already have same application running in your local system , then you can just move it to AWS , using below steps :-
spin up new ec2 instance, if you are using a free-tier then you can spin up lots of AWS resources for free , more information on https://aws.amazon.com/free/ .
install all the required s/w like Java, maven , tomcat and mysql and whatever your application is using on Ec2 instance . you can even have a free RDS (Database) instance in free tier which you can use for your application , instead of having the database installed locally on your application server.
while creating the ec2 server , configure instance security group properly for ex 8080 for http and 22 for SSH , 3306 for mysql etc. (This is important and try to be as restrtict as possible to make it safe from hackers).
build and deploy your application and access it using any REST client , by giving instance ip and application port number.
There are several resources online for AWS , you can refer https://www.youtube.com/watch?v=oS7VYX7LXUo which talks about deploying a java application to AWS.
Let me know if you need any other information.
Deploying Java apps (for example, a Spring BOOT APP) that interacts with the Amazon Relational Database Service (Amazon RDS) to the cloud is easy when using Elastic Beanstalk. An example of a Spring Boot database application that queries data from MySQL running on the cloud is documented here: https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_secure_spring_app

How to access Tomcat libraries for Java application on Elastic Beanstalk

Is there a relatively easy way to add jar files to Tomcat 7 folders in the Elastic Beanstalk cloud (specifically WEB-INF/lib)? I use Netbeans 7.3 and try to connect to a RDS database instance.

Deployed Tomcat 6 webapp can't connect to Amazon RDS Oracle instance

We are building a Java Spring-based web application that accesses an Oracle backend via Hibernate.
Here is our stack/tools:
Tomcat 6
Maven 3
Spring (mvc, web, orm) 3.2.0
Hibernate 4.1.9
Oracle 11g Release 2
Intellij IDEA.
To access the RDS from our local machines, we are port forwarding localhost:2521 to our-rds-instance-name.wercytsdzeszx.us-east-1.rds.amazonaws.com:1521
We are running embedded Tomcat using the tomcat6-maven-plugin. Our Maven configuration for testing is clean package tomcat6:run-war-only. This will deploy the WAR file to http://app.local:8080/our-app-name/ and allow us to test the site through this link.
Using Hibernate, we can connect successfully to the RDS instance when we are running the web app from our local embedded Tomcat instances.
HOWEVER - this is where it gets stupid - when we deploy the WAR file to our EC2 instance (which is part of a security group that has access to the RDS instance), the application can no longer access the database. We receive this error:
org.hibernate.exception.GenericJDBCException: Could not open connection
This is boggling my mind. We have installed SQLPlus on our EC2 instance running Tomcat and we can connect to the RDS instance, so the EC2 instance does have access to connect to the RDS instance.
Our local connection string would look something like this:
*jdbc:oracle:thin:USER_NAME/password#localhost:2521/sid*
Our EC2 (staging) instance connection string would look like this:
*jdbc:oracle:thin:USER_NAME/password#our-rds-instance-name.wercytsdzeszx.us-east-1.rds.amazonaws.com:1521/sid*
I can provide more details, but I first wanted to get the main problem out there so I don't muddy the waters with useless information.
I appreciate all feedback.
Tony
I have solved this problem.
It turns out there was an Oracle timezone error (ORA-01882: timezone region not found) that was the culprit. The Ubuntu server we are using for our EC2 AMI had a default timezone set that I guess was not recognized by Java or Oracle. I had seen that error, but ignorantly thought it could not be related to a database connectivity error.
We used the dpkg-reconfigure tzdata command to set the timezone to the correct one and restarted Tomcat. This allowed us to connect successfully to the Oracle database.
Tony

Categories