4

I am trying to deploy an application to EC2 with elastic beanstalk and tomcat. In order to try and fix a different problem I had I changed my uploaded file from a .war to a .zip in order to include a .ebextensions folder. However, now I get the following error when trying to enter the website:

enter image description here

I figured that there might be a problem with the .config file I added, so I tried zipping the .war file alone, however I get the exact same error, so this is ruled out.

1 Answers1

3

TL/DR: Put 2 .war files in the .zip file instead of 1.

I realize this post is nearly 18 months old. But I experienced exactly the same symptoms, so this seemed as good a place as any to share my discovery.

Premise: deploying a .war file works well, exactly as expected.

Observation: Elastic Beanstalk does this automatically:

/usr/share/tomcat/webapps/ROOT/[contents of .war are placed here]

Problem: deploying a .zip file containing this .war file along with valid config files does NOT work well.

Observation: Elastic Beanstalk does this automatically:

/usr/share/tomcat/webapps/ROOT/[my-war.war is placed here]

To me this seems like a bug. Perhaps it's intended behavior... but I don't understand it. Placing the .war file in webapps would make sense. Placing the contents of the .war in ROOT would make sense. But placing the .war file there directly seems very strange.

Solution: Add a second .war file to the .zip (even if you don't need the second app!).

Observation: Elastic Beanstalk does this automatically:

/usr/share/tomcat/webapps/[my-war.war is placed here]
/usr/share/tomcat/webapps/[my-other-war.war is placed here]

Now my-war.war deploys normally, and life is good.

mdahlman
  • 9,204
  • 4
  • 44
  • 72
  • 1
    It's definitely a bug! https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html `To run multiple applications on the same web server, you can bundle multiple WAR files into a single source bundle. Each application in a multiple WAR source bundle runs at the root path (ROOT.war runs at myapp.elasticbeanstalk.com/) or at a path directly beneath it (app2.war runs at myapp.elasticbeanstalk.com/app2/), as determined by the name of the WAR. In a single WAR source bundle, the application always runs at the root path.` It specifically says a single WAR bundle runs at /. – Chloe Nov 26 '18 at 00:38
  • Wow this is an amazing find! Don't forget that your app has to be called `ROOT.war` in order to be deployed on the `/` root path. – Chloe Nov 26 '18 at 22:25
  • I agree that it is a bug. Thanks for posting your solution! – Asencion Jan 09 '19 at 01:04