Teevity / ice

AWS Usage Tool
2.86k stars 435 forks source link

Deploying with Tomcat - The requested metadata was not found #208

Closed nbasu02 closed 8 years ago

nbasu02 commented 8 years ago

Related somewhat to #85

As per that issue, the following error comes up when -Dice.s3AccessKeyId and -Dice.s3SecretKey are not set:

com.amazonaws.AmazonClientException: The requested metadata is not found at http://169.254.169.254/latest/meta-data/iam/security-credentials/

Setting these as command line params when running ./grailsw run-app makes the app work as expected. However when trying to deploy via tomcat, the error comes back (when observed in /var/log/tomcat7/catalina.out).

I have tried the following:

  1. Setting ice.s3AccessKeyId and ice.s3SecretKey in ice/src/java/ice.properties and /var/lib/tomcat7/webapps/ice/WEB-INF/classes/ice.properties.
  2. Setting $JAVA_OPTS and $CATALINA_OPTS environmental variables in ~/.bashrc. Running echo on both confirms they are set.

My steps for deployment are as follows:

grails clean
grails war
sudo cp target/ice.war /var/lib/tomcat7/webapps/
sudo chown tomcat7:tomcat7 /var/lib/tomcat7/webapps/ice.war
sudo service tomcat7 restart
ghaber commented 8 years ago

Hi,

Try to pass them in etc/tomcat/tomcat.conf, here is my value:

JAVA_OPTS="-server -Xms1024m -Xmx1024m -Xss256k -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dnetworkaddress.cache.ttl=15 -Dsun.lang.ClassLoader.allowArraySyntax=true -Djava.awt.headless=true -DonlyRegions=eu-west-1 -Dice.s3AccessKeyId=xxxxxxxx -Dice.s3SecretKey=xxxxxxxxxx"

in my case, it works.

Regards

nbasu02 commented 8 years ago

Thanks for the reply. I ended up getting it working via supervisor, but hopefully this answer will help out someone who finds this in the future.