aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
743 stars 213 forks source link

SAM CLI fails to build #3826

Open al3x3i opened 1 year ago

al3x3i commented 1 year ago

Describe the bug Unable to Sync Servlets Application in IntelliJ. It fails while building the project. The sam build command works in the terminal as expected without any error. If I build the project first in terminal and then run the Sync Servlets Application the operation will be completed because sam uses build cache (from .aws-sam in the project folder) (Note: java is installed by sdkman). Unfortunately I cannot say whether it is related to a specific version or not, because I am using the AWS toolkit for the first time

To reproduce 1 sam init

  1. Sync template.yaml by AWS toolkit

Expected behavior Can build and deploy to the AWS by AWS toolkit

Your Environment

Additional context

/usr/local/bin/sam sync --stack-name HelloStack --template-file /home/temp/sam-test/sam-init-example/template.yaml --s3-bucket al33-x-lambda-packages --capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND --no-dependency-layer --no-watch

The SAM CLI will use the AWS Lambda, Amazon API Gateway, and AWS StepFunctions APIs to upload your code without 
performing a CloudFormation deployment. This will cause drift in your CloudFormation stack. 
**The sync command should only be used against a development stack**.

Confirm that you are synchronizing a development stack.

Enter Y to proceed with the command, or enter N to cancel:
 [Y/n]: Cache is invalid, running build and copying resources for following functions (HelloWorldFunction)
Building codeuri: /home/temp/sam-test/sam-init-example/HelloWorldFunction runtime: java11 metadata: {} architecture: x86_64 functions: HelloWorldFunction
Running JavaMavenWorkflow:CopySource
Running JavaMavenWorkflow:MavenBuild

Build Failed
Error: JavaMavenWorkflow:MavenBuild - Maven Failed: [INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< helloworld:HelloWorld >------------------------
[INFO] Building A sample Hello World created for SAM CLI. 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ HelloWorld ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/tmprg80f1cw/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloWorld ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /tmp/tmprg80f1cw/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.390 s
[INFO] Finished at: 2023-08-23T00:58:40+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project HelloWorld: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
vchikoti1998 commented 1 year ago

It says, [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Try these steps to resolve:

Kindly notify,  if you experience the same error again.

al3x3i commented 1 year ago

@vchikoti1998 Still does not work. -> If I try to update an existing Lambda Function by clicking "Update Function Code" in IntelliJ it works fine. -> If I try to deploy by using a sam template (template.yaml in the same project) it fails because of "Running JavaMavenWorkflow:MavenBuild" error. For me, it is very strange. My workaround is just to go to the terminal, call sam build and then "Sync Serverless Application"

If I can build the project by sam build in Linux terminal, I assume all configurations are fine.

Is there a place where can I collect logs from your plugin?