Frage

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

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top