Azure / azure-functions-java-worker

Java runtime and core types for Microsoft Azure Functions
MIT License
87 stars 54 forks source link

Binding Error - ExecutionContextDataSource cannot be cast to java.lang.String #753

Closed jumper404 closed 6 months ago

jumper404 commented 6 months ago

For the below azure app function in java ->

@functionName("GetLicense") public HttpResponseMessage getLicense( @HttpTrigger( name = "getLicense", methods = {HttpMethod.GET}, authLevel = AuthorizationLevel.ANONYMOUS, route = "license/getLicenseDetails/{customerCode}") @BindingName("customerCode") String customerCode, HttpRequestMessage<?> request, final ExecutionContext context )

Stack Trace-> Executed 'Functions.GetLicense' (Failed, Id=92f0807b-2414-4947-8f2e-9401b37d84f8, Duration=22ms) [2024-03-08T09:14:42.256Z] System.Private.CoreLib: Exception while executing function: Functions.GetLicense. System.Private.CoreLib: Result: Failure Exception: ClassCastException: class com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource cannot be cast to class java.lang.String (com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') Stack: java.lang.ClassCastException: class com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource cannot be cast to class java.lang.String (com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap') [2024-03-08T09:14:42.259Z] at com.microsoft.azure.functions.worker.binding.DataOperations.apply(DataOperations.java:99) [2024-03-08T09:14:42.260Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByType(DataSource.java:56) [2024-03-08T09:14:42.261Z] at com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource.computeByType(ExecutionContextDataSource.java:21) [2024-03-08T09:14:42.262Z] at com.microsoft.azure.functions.worker.binding.BindingDataStore.getDataByType(BindingDataStore.java:71) [2024-03-08T09:14:42.263Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:50) [2024-03-08T09:14:42.264Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolveArguments(ParameterResolver.java:22) [2024-03-08T09:14:42.265Z] at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:20) [2024-03-08T09:14:42.266Z] at com.microsoft.azure.functions.worker.chain.FunctionExecutionMiddleware.invoke(FunctionExecutionMiddleware.java:19) [2024-03-08T09:14:42.267Z] at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21) [2024-03-08T09:14:42.268Z] at io.quarkus.azure.functions.runtime.QuarkusAzureFunctionsMiddleware.invoke(QuarkusAzureFunctionsMiddleware.java:19) [2024-03-08T09:14:42.270Z] at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21) [2024-03-08T09:14:42.272Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:125) [2024-03-08T09:14:42.273Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34) [2024-03-08T09:14:42.274Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10) [2024-03-08T09:14:42.275Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44) [2024-03-08T09:14:42.276Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94) [2024-03-08T09:14:42.277Z] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [2024-03-08T09:14:42.278Z] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [2024-03-08T09:14:42.279Z] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [2024-03-08T09:14:42.280Z] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [2024-03-08T09:14:42.281Z] at java.base/java.lang.Thread.run(Thread.java:834) [2024-03-08T09:14:42.282Z] .

jumper404 commented 6 months ago

@functionName("GetLicense") public HttpResponseMessage getLicense( @HttpTrigger( name = "getLicense", methods = {HttpMethod.GET}, authLevel = AuthorizationLevel.ANONYMOUS, route = "license/getLicenseDetails/{customerCode}") HttpRequestMessage<?> request, @BindingName("customerCode") String customerCode, final ExecutionContext context )

It was an ordering problem