Skip to content

Experimental: null pointer exception when using exportAs #1018

@fjtirado

Description

@fjtirado

when using this workflow

return workflow("investment-memo")
        .tasks(
                get("fetchMarketData", "[http://localhost:8081/market-data/{ticker}](http://localhost:8081/market-data/%7Bticker%7D)")
                        .exportAs(result -> new InvestmentPrompt(
                                result.ticker(), 
                                "",
                                "",
                                ""), MarketDataSnapshot.class)

then following exception is thrown

2025-11-26 18:23:13,440 ERROR [io.quarkus.vertx.http.runtime.QuarkusErrorHandler] (vert.x-eventloop-thread-1) HTTP Request to /investments/CSU.TO failed, error id: 687f4df4-c30a-49b6-afc6-df9f0c9e664c-1: java.lang.NullPointerException: Cannot invoke "io.serverlessworkflow.impl.WorkflowModel.as(java.lang.Class)" because "n" is null
	at io.serverlessworkflow.impl.expressions.func.JavaExpressionFactory.lambda$buildExpression$1(JavaExpressionFactory.java:47)
	at io.serverlessworkflow.impl.expressions.AbstractExpressionFactory.lambda$buildFilter$5(AbstractExpressionFactory.java:61)
	at io.serverlessworkflow.impl.executors.AbstractTaskExecutor.lambda$apply$11(AbstractTaskExecutor.java:275)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at io.serverlessworkflow.impl.executors.AbstractTaskExecutor.lambda$apply$14(AbstractTaskExecutor.java:272)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1773)

When using YAML not initilizing the context is fine because JQ is more tolerant with null than java, but it has to be initialized for java

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions