【问题标题】:AWS Elastic Beanstalk Tomcat works with .war but not .zipAWS Elastic Beanstalk Tomcat 适用于 .war 但不适用于 .zip
【发布时间】:2017-09-08 15:01:56
【问题描述】:

我正在尝试使用弹性 beanstalk 和 tomcat 将应用程序部署到 EC2。为了尝试解决不同的问题,我将上传的文件从 .war 更改为 .zip 以包含 .ebextensions 文件夹。但是,现在我在尝试进入网站时收到以下错误:

我认为我添加的 .config 文件可能有问题,所以我尝试单独压缩 .war 文件,但我得到完全相同的错误,因此排除了这种情况。

【问题讨论】:

  • 日志是怎么说的?
  • @stdunbar 似乎没有向日志中添加任何内容。我查看了最后 100 行,它们都与以前的问题有关。

标签: amazon-web-services tomcat amazon-ec2 amazon-elastic-beanstalk


【解决方案1】:

TL/DR:将 2 个 .war 文件放入 .zip 文件中,而不是 1 个。

我知道这篇文章已经发布了将近 18 个月。但我经历了完全相同的症状,所以这似乎是一个分享我发现的好地方。

前提:部署 .war 文件效果很好,完全符合预期。

观察:Elastic Beanstalk 会自动执行此操作:

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

问题:部署包含此 .war 文件以及有效配置文件的 .zip 文件无法正常工作。

观察:Elastic Beanstalk 会自动执行此操作:

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

对我来说,这似乎是一个错误。也许这是预期的行为......但我不明白。将 .war 文件放在 webapps 中是有意义的。将 .war 的 contents 放在 ROOT 中是有意义的。但是直接把.war文件放在那里好像很奇怪。

解决方案:将第二个 .war 文件添加到 .zip 中(即使您不需要第二个应用程序!)。

观察:Elastic Beanstalk 会自动执行此操作:

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

现在my-war.war部署正常,生活不错。

【讨论】:

  • 这绝对是一个错误! docs.aws.amazon.com/elasticbeanstalk/latest/dg/… 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. 它明确表示单个 WAR 包在 / 处运行。
  • 哇,这是一个了不起的发现!不要忘记,您的应用必须调用 ROOT.war 才能部署在 / 根路径上。
  • 我同意这是一个错误。感谢您发布您的解决方案!
猜你喜欢
  • 2018-10-01
  • 2016-04-02
  • 2018-07-29
  • 2012-10-10
  • 1970-01-01
  • 2016-01-08
  • 1970-01-01
  • 1970-01-01
  • 2017-07-04
相关资源
最近更新 更多