Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java outputs has null exception #118

Open
gongxh13 opened this issue Mar 8, 2023 · 6 comments
Open

java outputs has null exception #118

gongxh13 opened this issue Mar 8, 2023 · 6 comments
Assignees

Comments

@gongxh13
Copy link

gongxh13 commented Mar 8, 2023

When I deploy java demo according this link https://github.com/OpenFunction/samples/tree/main/functions/knative/java/with-output-binding, after deploy, I access function, but has exception as:

[main] INFO org.eclipse.jetty.server.Server - jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 18.0.1.1+2
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@6f5ffd5c{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@5e792d1b{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[main] INFO org.eclipse.jetty.server.Server - Started Server@ee6f42b2{STARTING}[11.0.9,sto=0] @397ms
plugin plugin-example:v1.0.0 exec pre hook for http function at 2023-03-08 11:01:55.Z
receive event: {"message":"Awesome OpenFunction!"}
Mar 08, 2023 11:01:55 AM dev.openfunction.invoker.runtime.SynchronizeRuntime$OpenFunctionServlet service
SEVERE: Failed to execute function
java.lang.NullPointerException: Cannot invoke "io.dapr.client.DaprClient.invokeBinding(java.lang.String, java.lang.String, byte[], java.util.Map)" because "this.daprClient" is null
        at dev.openfunction.invoker.context.UserContext.send(UserContext.java:116)
        at dev.openfunction.samples.OpenFunctionImpl.accept(OpenFunctionImpl.java:15)
        at dev.openfunction.invoker.runtime.SynchronizeRuntime$OpenFunctionServlet.service(SynchronizeRuntime.java:166)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:508)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1375)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1297)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
        at org.eclipse.jetty.server.Server.handle(Server.java:562)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
        at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
        at java.base/java.lang.Thread.run(Unknown Source)

From above, it may be not init dapr client for java sdk.

@benjaminhuo
Copy link
Member

@wrongerror user need to add annotation manually? https://openfunction.dev/docs/concepts/baas_integration/

@wanjunlei
Copy link
Member

When I deploy java demo according this link https://github.com/OpenFunction/samples/tree/main/functions/knative/java/with-output-binding, after deploy, I access function, but has exception as:

[main] INFO org.eclipse.jetty.server.Server - jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 18.0.1.1+2
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@6f5ffd5c{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@5e792d1b{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[main] INFO org.eclipse.jetty.server.Server - Started Server@ee6f42b2{STARTING}[11.0.9,sto=0] @397ms
plugin plugin-example:v1.0.0 exec pre hook for http function at 2023-03-08 11:01:55.Z
receive event: {"message":"Awesome OpenFunction!"}
Mar 08, 2023 11:01:55 AM dev.openfunction.invoker.runtime.SynchronizeRuntime$OpenFunctionServlet service
SEVERE: Failed to execute function
java.lang.NullPointerException: Cannot invoke "io.dapr.client.DaprClient.invokeBinding(java.lang.String, java.lang.String, byte[], java.util.Map)" because "this.daprClient" is null
        at dev.openfunction.invoker.context.UserContext.send(UserContext.java:116)
        at dev.openfunction.samples.OpenFunctionImpl.accept(OpenFunctionImpl.java:15)
        at dev.openfunction.invoker.runtime.SynchronizeRuntime$OpenFunctionServlet.service(SynchronizeRuntime.java:166)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:508)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1375)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1297)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
        at org.eclipse.jetty.server.Server.handle(Server.java:562)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
        at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
        at java.base/java.lang.Thread.run(Unknown Source)

From above, it may be not init dapr client for java sdk.

Add these annotations to the Function.

openfunction.io/enable-dapr: true
openfunction.io/dapr-service-mode: sidecar

@benjaminhuo
Copy link
Member

Add these annotations to the Function.

openfunction.io/enable-dapr: true
openfunction.io/dapr-service-mode: sidecar

All samples should work under both proxy and sidecar modes, why proxy mode doesn't work for java? @wanjunlei @wrongerror

@gongxh13
Copy link
Author

gongxh13 commented Mar 9, 2023

When I deploy java demo according this link https://github.com/OpenFunction/samples/tree/main/functions/knative/java/with-output-binding, after deploy, I access function, but has exception as:

[main] INFO org.eclipse.jetty.server.Server - jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 18.0.1.1+2
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@6f5ffd5c{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@5e792d1b{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[main] INFO org.eclipse.jetty.server.Server - Started Server@ee6f42b2{STARTING}[11.0.9,sto=0] @397ms
plugin plugin-example:v1.0.0 exec pre hook for http function at 2023-03-08 11:01:55.Z
receive event: {"message":"Awesome OpenFunction!"}
Mar 08, 2023 11:01:55 AM dev.openfunction.invoker.runtime.SynchronizeRuntime$OpenFunctionServlet service
SEVERE: Failed to execute function
java.lang.NullPointerException: Cannot invoke "io.dapr.client.DaprClient.invokeBinding(java.lang.String, java.lang.String, byte[], java.util.Map)" because "this.daprClient" is null
        at dev.openfunction.invoker.context.UserContext.send(UserContext.java:116)
        at dev.openfunction.samples.OpenFunctionImpl.accept(OpenFunctionImpl.java:15)
        at dev.openfunction.invoker.runtime.SynchronizeRuntime$OpenFunctionServlet.service(SynchronizeRuntime.java:166)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:508)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1375)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1297)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
        at org.eclipse.jetty.server.Server.handle(Server.java:562)
        at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
        at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
        at java.base/java.lang.Thread.run(Unknown Source)

From above, it may be not init dapr client for java sdk.

Add these annotations to the Function.

openfunction.io/enable-dapr: true
openfunction.io/dapr-service-mode: sidecar

I has try this and can work well. But another question is I has try go with-binding demo, it's can work well not need this annotation, demo link is https://github.com/OpenFunction/samples/tree/main/functions/knative/with-output-binding.
Can you explain this why?

Add these annotations to the Function.

openfunction.io/enable-dapr: true
openfunction.io/dapr-service-mode: sidecar

All samples should work under both proxy and sidecar modes, why proxy mode doesn't work for java? @wanjunlei @wrongerror

For java, just sidecar mode is well, but go two mode are well, whether is because openfunction has not complete this for java?

@benjaminhuo
Copy link
Member

benjaminhuo commented Mar 10, 2023

For java, just sidecar mode is well, but go two mode are well, whether is because openfunction has not complete this for java?

It's a bug, the proxy mode should work for Java as well. @wanjunlei has fix that.
@wanjunlei would you update all the readme, docs, samples to reflect the new java functions framework version?

@benjaminhuo
Copy link
Member

benjaminhuo commented Mar 13, 2023

For java, just sidecar mode is well, but go two mode are well, whether is because openfunction has not complete this for java?

@wanjunlei has fixed this you can delete the old builder @gongxh13 https://github.com/OpenFunction/samples/blob/main/functions/knative/java/with-output-binding/function-front.yaml#L18 and download the new one.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants