0

I have an instance of EC2 on which I've deployed a web application. The EC2 instance is Linux with Tomcat. The web app works just fine locally on my box, and it connects to an AWS RDS instance of MySQL.

When I deploy this web app to the EC2 instance, any page that requires a call to the DB doesn't load. I'm using Hibernate and at the point where I try to get a Hibernate session created, I get a NullPointerException. This is the same error I get on my local box if I delete the persistence.xml config file.

Inside my persistence.xml, I simply have a persistence-unit defined, as you would expect. Nothing fancy (and again, it works fine locally).

Why is persistence.xml config file not being found/discovered and loaded when the app runs on the EC2 instance?

Currently the config file is located here in the project:

/web/res/META-INF/persistence.xml

Any input is appreciated. Thanks!

AlexG
  • 1,596
  • 2
  • 17
  • 26

2 Answers2

1

Try to copy the META-INF folder with your persistence.xml to your src folder. I've had problems before where I couldn't load my persistence.xml because it wasn't in my classpath.

Desorder
  • 1,549
  • 12
  • 16
0

Ok, so I'm an idiot. I had the MySQL connector jar in the tomcat lib directory, so that all my projects automatically get to make use of it w/o me manually adding it to each project. But when you wrap stuff up in a war file and publish, it doesn't include those 'common' jars. As a side note, shouldn't those jars be included in the war? Seems strange to me that they aren't.

AlexG
  • 1,596
  • 2
  • 17
  • 26