I am working with an aws serverless architecture with spring boot application. When I some time build the project using sam build in intellij, I am getting the following error.
Building codeuri: . runtime: java11 metadata: {} functions: ['MedisproutApiFunction']
Running JavaMavenWorkflow:CopySource
Running JavaMavenWorkflow:MavenBuild
Build Failed
Error: JavaMavenWorkflow:MavenBuild - 'utf-8' codec can't decode byte 0xbb in position 150889: invalid start byte
It is not showing any other error details. If I remove the newly made code changes (even though it does not had any encoding code) this error will not come. Please help me to fix this.
Already checked this link, but no answer found.
I encountered the same problem today when trying to do a
sam buildon my machine for a Java 11 project built with Maven.I believe the problem is this:
I found some hits in Google where other SAM users encountered a similar problem. Unfortunately, the workaround involves messing with Python source code that was installed as part of the SAM CLI. I prefer not to do this, but I found no cleaner solution as of today.
WORKAROUND STEPS:
Execute your SAM build in debug mode with this command:
sam build --debugYou will see more details of what SAM is doing before the error is displayed.
When the build fails, take note of the Python file and line number where the error occurred. For me, it looked like this:
Find the offending Python file and open it in a text editor. For me, that file is:
C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\aws_lambda_builders\workflows\java_maven\maven.pyNOTE: On Windows, you need to do this step as an Administrator if the SAM CLI is installed under "Program Files".
For me, this was the Python function that was the source of the error:
Edit the code and change the "utf8" to a different character set code. This one worked for me:
Here is the official list of Python encodings, in case you need to try a different one on your own machine:
https://docs.python.org/3/library/codecs.html#standard-encodings
I saved my edits to the Python file, then ran the
sam buildagain. This time I get normal output from Maven displayed.