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

Main class can't be found #3

Closed mrcookiemstr closed 4 years ago

mrcookiemstr commented 4 years ago

Report type

Minimal steps to reproduce

download repo via git and go to the source code run mvn clean build run mvn azure-functions:run try calling function via curl -v http://localhost:7071/api/hello

Any log messages given by the failure

[12/14/2019 3:14:12 PM] Executed 'Functions.hello' (Failed, Id=40bb9d77-8a49-404c-98d6-c2ee5abeaaa5) [12/14/2019 3:14:12 PM] System.Private.CoreLib: Exception while executing function: Functions.hello. System.Private.CoreLib: Result: Failure [12/14/2019 3:14:12 PM] Exception: IllegalArgumentException: Failed to locate main class [12/14/2019 3:14:12 PM] Stack: java.lang.IllegalStateException: Failed to discover main class. An attempt was made to discover main class as 'MAIN_CLASS' environment variable, system property as well as entry in META-INF/MANIFEST.MF (in that order). [12/14/2019 3:14:12 PM] at org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer.getStartClass(AbstractSpringFunctionAdapterInitializer.java:288) [12/14/2019 3:14:12 PM] at org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer.(AbstractSpringFunctionAdapterInitializer.java:100) [12/14/2019 3:14:12 PM] at org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler.(AzureSpringBootRequestHandler.java:44) [12/14/2019 3:14:12 PM] at com.example.HelloHandler.(HelloHandler.java:15) [12/14/2019 3:14:12 PM] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [12/14/2019 3:14:12 PM] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [12/14/2019 3:14:12 PM] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [12/14/2019 3:14:12 PM] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [12/14/2019 3:14:12 PM] at java.lang.Class.newInstance(Class.java:442) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.lambda$execute$1(JavaMethodExecutor.java:54) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:20) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:54) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:53) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45) [12/14/2019 3:14:12 PM] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92) [12/14/2019 3:14:12 PM] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [12/14/2019 3:14:12 PM] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [12/14/2019 3:14:12 PM] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [12/14/2019 3:14:12 PM] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [12/14/2019 3:14:12 PM] at java.lang.Thread.run(Thread.java:748) [12/14/2019 3:14:12 PM] Caused by: java.lang.IllegalArgumentException: Failed to locate main class

Expected/desired behavior

I should be able to call the function without any problem

OS and Version?

Ubuntu 19

Versions

java version 8.0.222.hs-adpt azure-functions-core-tools@3 maven version 3.6.2

jdubois commented 4 years ago

Yes, it's the same as #1 and #2 I thought it would be solved quicker by the team - there's a workaround by @Flanker32 at https://github.com/microsoft/azure-maven-plugins/issues/912#issuecomment-561188815 that I should implement, so it will be solved while waiting for the real fix from the engineering team

mrcookiemstr commented 4 years ago

Thanks for quick response.

jdubois commented 4 years ago

I'm going to push the fix (and this will close this ticket automatically) following the solution from @Flanker32 but this means we will commit a local.settings.xml file, and normally this shouldn't be in Git (it should be local). So it works, but that's temporary, waiting for the real fix to come from the Azure Functions team.