I am trying to use the openwhisk-java-plugin
and here is the serverless.yaml
service: helloworld
frameworkVersion: ">=1.2.0 <2.0.0"
provider:
name: openwhisk
runtime: java
ignore_certs: true
package:
artifact: target/demo-function.jar
functions:
demo:
handler: com.example.FunctionApp
plugins:
- "serverless-openwhisk"
When I try to deploy the function I get the following error
Serverless: Packaging function: demo...
Serverless Error ---------------------------------------
Function handler (com.example.FunctionApp) does not exist.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: darwin
Node Version: 10.0.0
Serverless Version: 1.27.2
I assume the handler for Java with jar should pass that as appropriate parameter to the underlying provider.
Can you please let me know if something missing ???
-Kamesh
The Java template looks like the default serverless.yml contains a bug.
If you change the configuration to the following template it works.
service: helloworld
provider:
name: openwhisk
runtime: java
# you can add packaging information here
functions:
demo:
handler: target/demo-function.jar:com.example.FunctionApp
plugins:
- "serverless-openwhisk"
Thanks James, with that modified configuration I could move past the original error. However there is a new error:
$ sls deploy
Serverless: Packaging service...
Serverless: Compiling Functions...
Serverless Error ---------------------------------------
Unable to read handler file in function demo
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information -----------------------------
OS: darwin
Node Version: 8.11.2
Serverless Version: 1.32.0
I extracted the .jar and the .class is definitely there.
It looks like Shaz found the fix for this issue
serverless:master
← shazron:javafix
opened 04:01PM - 05 Oct 18 UTC
Fixes #138
In the base class base.js function `getArtifactZip`, we already r… ead the zipfile into a buffer https://github.com/serverless/serverless-openwhisk/blob/7ffcbef78a52110d1817b32333a4cb4487da9d57/compile/functions/runtimes/base.js#L83 . This is then passed to the subclass' `processActionPackage` function, in this case in java.js https://github.com/serverless/serverless-openwhisk/blob/7ffcbef78a52110d1817b32333a4cb4487da9d57/compile/functions/runtimes/java.js#L36, which thinks the `zip` parameter is a `JSZip` object, thus it all fails with a NPE since `zip.file` does not evaluate. We just need to`return zip` in the function.
On a cursory review, I think other runtimes may make this mistake as well I think: https://github.com/serverless/serverless-openwhisk/search?q=processActionPackage&unscoped_q=processActionPackage