1

I am trying to create a pipeline for an existing application. It is a React/Java Spring Boot application. It usually gets bundled into a single war file and uploaded to ElasticBeanstalk. I created my codebuild project and when I run it manually it will generate a war file that I can then upload to ElasticBeanstalk and everything works correctly. The buildspec for that is below:

version: 0.2

phases:
  install:
    commands:
      - echo Nothing to do in the install phase...
  pre_build:
    commands:
      - echo Nothing to do in the pre_build phase...
  build:
    commands:
      - echo Build started on `date`
      - mvn -Pprod package -X
  post_build:
    commands:
      - echo Build completed on `date`
      - mv target/cogcincinnati-0.0.1-SNAPSHOT.war cogcincinnati-0.0.1-SNAPSHOT.war
artifacts:
  files:
    - cogcincinnati-0.0.1-SNAPSHOT.war

When I run this build step in my pipeline it generates a zip file that gets dropped onto S3. My deploy step takes that build artifact and sends it to ElasticBeanstalk. Elasticbeanstalk does not give me any errors, but when I navigate to my url, I get a 404.

I have tried uploading the zip directly to Elasticbeanstalk and I get the same result. I have unzipped the file and it does appear to have all of my project files.

When I look at the server logs, I do not see any errors. I don't understanding why codebuild appears to be generating a war file when I run it manually, but a zip when executed in code pipeline.

2
  • Are you deploying under a context path? If so, please read about setting the base href on jhipster.tech/production/#building-an-executable-jar--war-file Jun 4, 2020 at 14:04
  • I updated my reference to new BaseHrefWebpackPlugin({ baseHref: '/cogcincinnati/' }) and redeployed. It didn't work. I think you're probably correct that it is probably incorrect. I think the underlying issue is that it isn't deploying the correct profile.
    – Topher
    Jun 4, 2020 at 19:32

3 Answers 3

1

Change artifacts war file name to ROOT.war this will resolve your problem actually your application is deployed successfully but on a different path, this is tomcat inbuild functionality by changing the ROOT it will run the application on '/'

So updated buildspec.yml will be

version: 0.2

phases:
  install:
    commands:
      - echo Nothing to do in the install phase...
  pre_build:
    commands:
      - echo Nothing to do in the pre_build phase...
  build:
    commands:
      - echo Build started on `date`
      - mvn -Pprod package -X
  post_build:
    commands:
      - echo Build completed on `date`
      - mv target/cogcincinnati-0.0.1-SNAPSHOT.war ROOT.war
artifacts:
  files:
    - ROOT.war


0

Seems your application is failing, you should review the logs from the Beanstalk environment, specially:

  • "tomcat8/catalina.out"
  • "tomcat8/catalina.[date].log"

[1] Viewing logs from Amazon EC2 instances in your Elastic Beanstalk environment - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html

For more details about using Tomcat platform on EB environment, you can refer to this document: - Using the Elastic Beanstalk Tomcat platform - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform.html

About the folder structuring in your project, please refer to this document: - Structuring your project folder - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-platform-directorystructure.html

0

Try adding discard-paths: yes at the end of the buildspec.yml file. That will help you resolving the path error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.