I have an EC2 instance on AWS configured with Apache tomcat 8 and java.
Following some tutorials from here, I can create one .war of my Web Service in eclipse and put it inside webapps folder of tomcat in my EC2 instance.
I am able to access this services from the IP address of EC2 with the specific port and .war file name.
For example:
IPADDRESS:8080/MyApplication.
And everything seems to work fine, I can open the services and see the wsdl files. My Web Service (in .war file) is configured for make a connection with a RDS instance from amazon.
The connection itself is ok, I tested in localhost a direct connection with RDS from Android.
But, when I try to connect with services that I put in EC2 (from there
the connection with my RDS is created) from Android, no data returns and I get a Null Pointer.
The link that I used to make a connection with EC2 from Android is the Public IP of EC2 and the port (8080), followed by the specific path of wsdl file.
For example:
http://99.999.999.99:8080/MyApplication/services/SomeServiceName?wsdl
I am using the KSOAP library to consume web service on Android side and I
have no idea of the reason that I don't get data from EC2 instance.
All methods in the web service and the comsumption in Android works fine, I tested all in local host.
I tested all my methods of web service using SOAP UI, and all of them is working
For test the RDS instance that contains my DB, I run the web service in localhost with tomcat 8 and the communication Android -> My PC (localhost) -> RDS instance (My DB) is working.
The problem are when I try to change the communication line from:
*Android -> My PC (localhost) -> RDS instance (My DB)*
TO:
*Android -> EC2 instance -> RDS instance (My DB)*
Again, in EC2 I make the deploy of my web service.
I use the same security group for RDS and EC2:
Inbound rules:
http://i.stack.imgur.com/RUdyl.png
Outbound rules:
http://i.stack.imgur.com/W4gLc.png
I finally solved the problem.
I did the following:
I connected to my ECB2 instance and open the tomcat 8 log, so I saw that the error was ClassNotFoundException, related to Postgres (my engine DB).
I opened my web service eclipse project and saw this (stupid) error:
The .jar postgres driver was in that lib folder:
Instead of that folder:
So, basically, when I did the deploy of my Web service in EC2 instance the postgres driver does not go together.
Thanks for the help, I hope that helps someone else.
Related
I have a java application that is deployed on AWS EC2 instance. This application is connecting to an AWS RDS db. This works fine. But from my local windows when I debug the code in intellij, it is not able to connect to db because it require an ssh key and EC2 instance ip for connection along with password.
Java application uses oracle hibernate connection with entity manager.
I came across this solution
https://www.jetbrains.com/help/idea/connectivity-problems.html#step-4-check-if-the-connection-with-ssh-ssl
but I don't see SSH configuration option on Tool windows in my Intellij.
Could someone help me on how can I make db connection using java application using intellij or by deploying application in tomcat in my local?
im new to aws and i have succssefully deployed war file but im still getting a JDBC connection error before i generated the war. Cant figure out what im doing wrong. any help?
heres my application.properties file
heres the error
To learn how to build a Java web app that stores app data in an Amazon RDS MySQL instance and then how to deploy the web app to the cloud, see this doc. It walks you through the process. Make sure you set your inbound rules properly and you specify your database connection string. If you can connect from your local machine but not Elastic Beanstalk - looks like you did not setup the inbound rule to allow a connection.
Creating the Amazon Relational Database Service item tracker
I have hosted a play framework web application on Amazon EC2 instance. The application is not able to connect to a mysql database located on the Amazon RDS instance. When I run the play framework web application on my local computer it successfully connects to the database on the Amazon RDS instance. I checked the database connection credentials in the production conf file many times. Looks correct.
When I do
mysql -h********.rds.amazonaws.com -p****** -u****** db_name
from the local computer it quickly connects. But when I try same connection to RDS from EC2 it throws:
ERROR 2003 (HY000): Can't connect to MySQL server on ********.rds.amazonaws.com
Can anyone kindly help me with this or suggest anything that I may be possibly missing.
Is RDS in VPC?
Yes, Check if EC2 is also in VPC or not.
No, Check security group that EC2 is in, allows the communication over database port
For more info and scenarios, head here
I have 2 projects.
Spring Restful Webservice
AngularJS
Database is MySQL.
i am new to AWS, I want to host my application using AWS. So i want to deploy these projects on AWS.
When i create MySQL database on AWS, then what will be the DB_URL then i can use it on my java application.
When i deploy the WAR file on AWS, then what will be the URL then i can use it on my AngularJS application
Database: use RDS Mysql. After create, go detail of RDS instance you will get RDS Endpoint with this pattern: RDS_INSTANCE_NAME.XXXXXXXXXXX.ap-northeast-1.rds.amazonaws.com and default port 3306. You can access this RDS with that endpoint and user/pass as the local database (Import/export, Create schema,...)
About the web layer, you can create 2 EC2 instances: 1 for Web-service, 1 for AngrulaJS or create 1 EC2 instance and deploy both of them into that EC2 instance.
You need SSH key to access via ssh. Then install your web container into EC2 instances and deploy as local server
AngrulaJS web: There are many ways to public your app:
you can use Route53 to create A Record point to public IP of EC2 instance (Containt AngrularJS app)
Use Internet-facing ELB point to EC2 instance.
Use public IP that associated to EC2 instance.
I found a clearly architect design in this, you can reference it https://creately.com/diagram/example/h4gr4x8d4/3-Tier%20Architecture
When you deploy the application in EC2.
You have Public DNS (IPv4) value for Ec2 ec2-xx-xx-xx-xx.compute-1.amazonaws.com. You will use this endpoint for WAR file.
If you do not assign Elastic ip for the EC2 Instance when you stop and start instance the ip address changed for Instance.
Based on your requirements you can leverage other services like Load Balancer and Route53.
I am trying to learn webservice building/deployment. I have built a webservice and deployed it on a oracle weblogic server on my laptop.
i am trying to test the webservice using soapUI from another laptop. i am getting invalid URL error.
can some one point out where i am going wrong
Note the same wsdl works fine if i try to run it from SoapUI on my laptop
Laptops have to be on same network. If so, each laptop will have its local Ip address ( go to cmd promt if using windows and type ipconfig).
Using this Ip, you can access webservice from second laptop which is hosted on your laptop.
If they are not on same network, it is possible but there are lots of things to be considered. I would suggest that only for production applications, not for testing.