Azure-Samples / hello-spring-function-azure

Example "Hello, world" Spring Boot application that runs on Azure Functions
MIT License
68 stars 87 forks source link

Function Execution Fail #4

Closed spdeepak closed 4 years ago

spdeepak commented 4 years ago

Cloned the project locally and followed the steps mentioned and I get the below error

This issue is for the curl command below

curl http://localhost:7071/api/hello -d "{\"name\":\"Azure\"}"

[02/14/2020 13:02:53] Executing 'Functions.hello' (Reason='This function was programmatically called via the host APIs.', Id=59830cdc-0263-4fa2-8e9d-8b1c5ff67e9e)
[02/14/2020 13:02:53] Executed 'Functions.hello' (Failed, Id=59830cdc-0263-4fa2-8e9d-8b1c5ff67e9e)
[02/14/2020 13:02:53] System.Private.CoreLib: Exception while executing function: Functions.hello. System.Private.CoreLib: Result: Failure
[02/14/2020 13:02:53] Exception: ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
[02/14/2020 13:02:53] Stack: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider.addUrlToSystemClassLoader(DefaultClassLoaderProvider.java:72)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider.addUrl(DefaultClassLoaderProvider.java:62)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.addSearchPathsToClassLoader(JavaFunctionBroker.java:64)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.loadMethod(JavaFunctionBroker.java:33)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.handler.FunctionLoadRequestHandler.execute(FunctionLoadRequestHandler.java:27)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.handler.FunctionLoadRequestHandler.execute(FunctionLoadRequestHandler.java:9)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[02/14/2020 13:02:53]   at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[02/14/2020 13:02:53]   at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[02/14/2020 13:02:53]   at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[02/14/2020 13:02:53]   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[02/14/2020 13:02:53]   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[02/14/2020 13:02:53]   at java.base/java.lang.Thread.run(Thread.java:834)
[02/14/2020 13:02:53] .
[02/14/2020 13:02:53] Executed HTTP request: {
[02/14/2020 13:02:53]   "requestId": "ac312cb5-33a4-4585-b703-168206cd827c",
[02/14/2020 13:02:53]   "method": "POST",
[02/14/2020 13:02:53]   "uri": "/api/hello",
[02/14/2020 13:02:53]   "identities": [
[02/14/2020 13:02:53]     {
[02/14/2020 13:02:53]       "type": "WebJobsAuthLevel",
[02/14/2020 13:02:53]       "level": "Admin"
[02/14/2020 13:02:53]     }
[02/14/2020 13:02:53]   ],
[02/14/2020 13:02:53]   "status": 500,
[02/14/2020 13:02:53]   "duration": 12
[02/14/2020 13:02:53] }

Just a side note; my local JDK version is 11 and not 8. But the java version for the project is JDK 8.

I changed my local JDK version to 8 still I get the same issue.

jdubois commented 4 years ago

That should be an easy one 😀

You've build/package your application with Java 11 -> indeed you are running it with Java 8, but you also need to build it with Java 8.

For example:

I'm closing because I'm sure this will solve the issue, but don't hesitate to comment, and I'll reopen if necessary.