Does serverless framework support GCP deployment for java functions?

I am trying to deploy an existing aws serverless stack to gcp, it is currently implemented by using java8.

I did a couple of tests by using python and it works. But I changed the handler to java class, I got this error

Error: The "handler" property for the function "bsFileTransferInitProcessor" is invalid. Handlers should be plain strings referencing only the exported function name without characters such as "." or "/" (so e.g. "http" instead of "index.http"). Do you want to nest your functions code in a subdirectory? Google solves this by utilizing the "main" config in the projects package.json file. Please check the docs for more info.
      at /home/leo/workspace/data-receipt-station/node_modules/serverless-google-cloudfunctions/shared/validate.js:50:15
      at /home/leo/workspace/data-receipt-station/node_modules/lodash/lodash.js:4925:15

So please advice when it is supported or any work-round for this issue?

Hi Leo,
did you solve it?

Hi @cotrariello , yeah I worked around by creating a Handler class in root package (under src/main/java), then that class extends the real handler.
I don’t think the GCP and Serverless fully support java Functions, suggest you to use python for new project. If like me, I already got some working code in Java and trying to deploy it to GCP, then here are some hints

  • java8 functions works well in java11 environment in GCP
  • the handler path issue you mentioned above
  • the serverless requires the artifact to be in a .zip file, so you need to put your jar into a zip file, then upload it
1 Like

Hi @leo7 , thank you for the reply. I also solved by putting the Java Handler Class in the root folder.
Only one question, what do you mean in the last point? Because I generate the jar artifact and it works fine.

Hi @cotrariello , that is good if you can use jar, instead of a zip file. That didn’t work for me, but I may give it another try

Hi @leo7 , with the new version of the framework it does not work for me too. So I deployed the function directly from the Google Console using the zip version as you suggest. Thank you.