Communication between Android and EC2 with RDS

349 views Asked by At

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:

https://i.stack.imgur.com/RUdyl.png

Outbound rules:

https://i.stack.imgur.com/W4gLc.png

1

There are 1 answers

0
Luiz On BEST ANSWER

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.