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

Unable to run test locally #14

Closed pomverte closed 4 years ago

pomverte commented 4 years ago

This issue is for a: (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

$ ./mvnw clean test package azure-functions:run
$ curl http://localhost:7071/api/hello -d "{\"name\":\"Azure\"}"

Any log messages given by the failure

./mvnw clean test package azure-functions:run
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.example:hello >--------------------------
[INFO] Building Hello Spring Function on Azure 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ hello ---
[INFO] Deleting /Users/pomverte/git/hello-spring-function-azure/target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/pomverte/git/hello-spring-function-azure/src/main/resources
[INFO] skip non existing resourceDirectory /Users/pomverte/git/hello-spring-function-azure/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/pomverte/git/hello-spring-function-azure/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/pomverte/git/hello-spring-function-azure/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/pomverte/git/hello-spring-function-azure/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ hello ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.HelloFunctionTest
14:52:11.305 [main] INFO org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer - Initializing: class com.example.HelloFunction

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.7.RELEASE)

2020-05-16 14:52:11.602  INFO 37140 --- [           main] o.a.maven.surefire.booter.ForkedBooter   : Starting ForkedBooter v2.22.2 on AMAC02X61ECJG5M with PID 37140 (started by pomverte in /Users/pomverte/git/hello-spring-function-azure)
2020-05-16 14:52:11.604  INFO 37140 --- [           main] o.a.maven.surefire.booter.ForkedBooter   : No active profile set, falling back to default profiles: default
2020-05-16 14:52:12.116  INFO 37140 --- [           main] o.a.maven.surefire.booter.ForkedBooter   : Started ForkedBooter in 0.741 seconds (JVM running for 1.405)
2020-05-16 14:52:12.120  INFO 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'function' with acceptedOutputTypes: []
2020-05-16 14:52:12.121  WARN 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'function' in function catalog. Function available in catalog are: [hello, functionRouter]
2020-05-16 14:52:12.121  INFO 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'consumer' with acceptedOutputTypes: []
2020-05-16 14:52:12.121  WARN 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'consumer' in function catalog. Function available in catalog are: [hello, functionRouter]
2020-05-16 14:52:12.121  INFO 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'supplier' with acceptedOutputTypes: []
2020-05-16 14:52:12.121  WARN 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : !!! Failed to discover function 'supplier' in function catalog. Function available in catalog are: [hello, functionRouter]
2020-05-16 14:52:12.122  INFO 37140 --- [           main] c.f.c.c.BeanFactoryAwareFunctionRegistry : Looking up function 'hello' with acceptedOutputTypes: []
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.049 s - in com.example.HelloFunctionTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/pomverte/git/hello-spring-function-azure/src/main/resources
[INFO] skip non existing resourceDirectory /Users/pomverte/git/hello-spring-function-azure/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/pomverte/git/hello-spring-function-azure/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/pomverte/git/hello-spring-function-azure/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/pomverte/git/hello-spring-function-azure/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ hello ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-dependency-plugin:3.1.2:copy-dependencies (copy-dependencies) @ hello ---
[INFO] Copying spring-cloud-function-adapter-azure-3.0.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-cloud-function-adapter-azure-3.0.6.RELEASE.jar
[INFO] Copying spring-cloud-function-context-3.0.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-cloud-function-context-3.0.6.RELEASE.jar
[INFO] Copying typetools-0.6.2.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/typetools-0.6.2.jar
[INFO] Copying spring-boot-autoconfigure-2.2.7.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-boot-autoconfigure-2.2.7.RELEASE.jar
[INFO] Copying spring-cloud-function-core-3.0.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-cloud-function-core-3.0.6.RELEASE.jar
[INFO] Copying spring-messaging-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-messaging-5.2.6.RELEASE.jar
[INFO] Copying spring-beans-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-beans-5.2.6.RELEASE.jar
[INFO] Copying jackson-databind-2.10.4.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/jackson-databind-2.10.4.jar
[INFO] Copying jackson-annotations-2.10.4.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/jackson-annotations-2.10.4.jar
[INFO] Copying jackson-core-2.10.4.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/jackson-core-2.10.4.jar
[INFO] Copying spring-boot-starter-2.2.7.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-boot-starter-2.2.7.RELEASE.jar
[INFO] Copying spring-boot-2.2.7.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-boot-2.2.7.RELEASE.jar
[INFO] Copying spring-context-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-context-5.2.6.RELEASE.jar
[INFO] Copying spring-boot-starter-logging-2.2.7.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-boot-starter-logging-2.2.7.RELEASE.jar
[INFO] Copying logback-classic-1.2.3.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/logback-classic-1.2.3.jar
[INFO] Copying logback-core-1.2.3.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/logback-core-1.2.3.jar
[INFO] Copying log4j-to-slf4j-2.12.1.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/log4j-to-slf4j-2.12.1.jar
[INFO] Copying log4j-api-2.12.1.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/log4j-api-2.12.1.jar
[INFO] Copying jul-to-slf4j-1.7.30.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/jul-to-slf4j-1.7.30.jar
[INFO] Copying jakarta.annotation-api-1.3.5.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/jakarta.annotation-api-1.3.5.jar
[INFO] Copying snakeyaml-1.25.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/snakeyaml-1.25.jar
[INFO] Copying reactor-core-3.3.5.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/reactor-core-3.3.5.RELEASE.jar
[INFO] Copying reactive-streams-1.0.3.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/reactive-streams-1.0.3.jar
[INFO] Copying azure-functions-java-library-1.2.2.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/azure-functions-java-library-1.2.2.jar
[INFO] Copying javax.annotation-api-1.3.2.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/javax.annotation-api-1.3.2.jar
[INFO] Copying spring-aop-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-aop-5.2.6.RELEASE.jar
[INFO] Copying spring-expression-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-expression-5.2.6.RELEASE.jar
[INFO] Copying slf4j-api-1.7.30.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/slf4j-api-1.7.30.jar
[INFO] Copying spring-core-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-core-5.2.6.RELEASE.jar
[INFO] Copying spring-jcl-5.2.6.RELEASE.jar to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/lib/spring-jcl-5.2.6.RELEASE.jar
[INFO]
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ hello ---
[INFO] Building jar: /Users/pomverte/git/hello-spring-function-azure/target/hello-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- azure-functions-maven-plugin:1.4.1:package (package-functions) @ hello ---
[WARNING] Azure Functions only support JDK 8, which is lower than local JDK version 11.0.7.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.microsoft.applicationinsights.core.dependencies.xstream.core.util.Fields (file:/Users/pomverte/.m2/repository/com/microsoft/azure/applicationinsights-core/2.5.1/applicationinsights-core-2.5.1.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.microsoft.applicationinsights.core.dependencies.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO]
[INFO] Step 1 of 7: Searching for Azure Functions entry points
[INFO] 1 Azure Functions entry point(s) found.
[INFO]
[INFO] Step 2 of 7: Generating Azure Functions configurations
[INFO] Generation done.
[INFO]
[INFO] Step 3 of 7: Validating generated configurations
[INFO] Validation done.
[INFO]
[INFO] Step 4 of 7: Saving host.json
[INFO] Successfully saved to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/host.json
[INFO]
[INFO] Step 5 of 7: Saving configurations to function.json
[INFO] Starting processing function: hello
[INFO] Successfully saved to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/hello/function.json
[INFO]
[INFO] Step 6 of 7: Copying JARs to staging directory/Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource to /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function
[INFO] Copied successfully.
[INFO] Step 7 of 7: Installing function extensions if needed
[INFO] Skip install Function extension for HTTP Trigger Functions
[INFO] Successfully built Azure Functions.
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:copy-resources (copy-resources) @ hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.7.RELEASE:repackage (repackage) @ hello ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- azure-functions-maven-plugin:1.4.1:run (default-cli) @ hello ---
[WARNING] Azure Functions only support JDK 8, which is lower than local JDK version 11.0.7.
[INFO] Azure Function App's staging directory found at: /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function
[INFO] Azure Functions Core Tools found.

                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (3.0.2245 Commit hash: 1d094e2f3ef79b9a478a1621ea7ec3f93ac1910d)
Function Runtime Version: 3.0.13139.0
[16/05/2020 12:52:19] FUNCTIONS_WORKER_RUNTIME set to java. Skipping WorkerConfig for language:python
[16/05/2020 12:52:19] FUNCTIONS_WORKER_RUNTIME set to java. Skipping WorkerConfig for language:powershell
[16/05/2020 12:52:19] FUNCTIONS_WORKER_RUNTIME set to java. Skipping WorkerConfig for language:node
[16/05/2020 12:52:19] Starting worker process:/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java  -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -noverify -Djava.net.preferIPv4Stack=true -jar "/usr/local/Cellar/azure-functions-core-tools@3/3.0.2245/workers/java/azure-functions-java-worker.jar" --host 127.0.0.1 --port 57061 --workerId 5764b5c5-4fa6-489c-b653-13330c895eaf --requestId 29f5485f-5fbf-4364-b8e9-376a1812468e --grpcMaxMessageLength 134217728
[16/05/2020 12:52:19] /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java process with Id=37192 started
[16/05/2020 12:52:20] [INFO] {Application.main}: Azure Functions Java Worker  version [ 1.5.2-SNAPSHOT]
[16/05/2020 12:52:20] [INFO] {MessageHandler.handle}: Message generated by "StartStream.Builder"
[16/05/2020 12:52:20] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'eaa707f1-4ce1-4fbc-9239-9e509425312c'
[16/05/2020 12:52:20] Reading host configuration file '/Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/host.json'
[16/05/2020 12:52:20] Host configuration file read:
[16/05/2020 12:52:20] {
[16/05/2020 12:52:20]   "version": "2.0",
[16/05/2020 12:52:20]   "functionTimeout": "00:10:00"
[16/05/2020 12:52:20] }
[16/05/2020 12:52:20] Reading functions metadata
[16/05/2020 12:52:20] 1 functions found
[16/05/2020 12:52:20] Initializing Warmup Extension.
[16/05/2020 12:52:21] FUNCTIONS_WORKER_RUNTIME set to java. Skipping WorkerConfig for language:python
[16/05/2020 12:52:21] FUNCTIONS_WORKER_RUNTIME set to java. Skipping WorkerConfig for language:powershell
[16/05/2020 12:52:21] FUNCTIONS_WORKER_RUNTIME set to java. Skipping WorkerConfig for language:node
[16/05/2020 12:52:21] Initializing Host. OperationId: 'eaa707f1-4ce1-4fbc-9239-9e509425312c'.
[16/05/2020 12:52:21] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=eaa707f1-4ce1-4fbc-9239-9e509425312c
[16/05/2020 12:52:21] LoggerFilterOptions
[16/05/2020 12:52:21] {
[16/05/2020 12:52:21]   "MinLevel": "None",
[16/05/2020 12:52:21]   "Rules": [
[16/05/2020 12:52:21]     {
[16/05/2020 12:52:21]       "ProviderName": null,
[16/05/2020 12:52:21]       "CategoryName": null,
[16/05/2020 12:52:21]       "LogLevel": null,
[16/05/2020 12:52:21]       "Filter": "<AddFilter>b__0"
[16/05/2020 12:52:21]     },
[16/05/2020 12:52:21]     {
[16/05/2020 12:52:21]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[16/05/2020 12:52:21]       "CategoryName": null,
[16/05/2020 12:52:21]       "LogLevel": "None",
[16/05/2020 12:52:21]       "Filter": null
[16/05/2020 12:52:21]     },
[16/05/2020 12:52:21]     {
[16/05/2020 12:52:21]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[16/05/2020 12:52:21]       "CategoryName": null,
[16/05/2020 12:52:21]       "LogLevel": null,
[16/05/2020 12:52:21]       "Filter": "<AddFilter>b__0"
[16/05/2020 12:52:21]     }
[16/05/2020 12:52:21]   ]
[16/05/2020 12:52:21] }
[16/05/2020 12:52:21] FunctionResultAggregatorOptions
[16/05/2020 12:52:21] {
[16/05/2020 12:52:21]   "BatchSize": 1000,
[16/05/2020 12:52:21]   "FlushTimeout": "00:00:30",
[16/05/2020 12:52:21]   "IsEnabled": true
[16/05/2020 12:52:21] }
[16/05/2020 12:52:21] SingletonOptions
[16/05/2020 12:52:21] {
[16/05/2020 12:52:21]   "LockPeriod": "00:00:15",
[16/05/2020 12:52:21]   "ListenerLockPeriod": "00:00:15",
[16/05/2020 12:52:21]   "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[16/05/2020 12:52:21]   "LockAcquisitionPollingInterval": "00:00:05",
[16/05/2020 12:52:21]   "ListenerLockRecoveryPollingInterval": "00:01:00"
[16/05/2020 12:52:21] }
[16/05/2020 12:52:21] HttpOptions
[16/05/2020 12:52:21] {
[16/05/2020 12:52:21]   "DynamicThrottlesEnabled": false,
[16/05/2020 12:52:21]   "MaxConcurrentRequests": -1,
[16/05/2020 12:52:21]   "MaxOutstandingRequests": -1,
[16/05/2020 12:52:21]   "RoutePrefix": "api"
[16/05/2020 12:52:21] }
[16/05/2020 12:52:21] Starting JobHost
[16/05/2020 12:52:21] Starting Host (HostId=amac02x61ecjg5m-722775187, InstanceId=542fe8ae-936d-4b42-9a20-c59067833016, Version=3.0.13139.0, ProcessId=37191, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
[16/05/2020 12:52:21] Loading functions metadata
[16/05/2020 12:52:21] 1 functions loaded
[16/05/2020 12:52:21] Generating 1 job function(s)
[16/05/2020 12:52:21] [INFO] {DefaultClassLoaderProvider.addUrl}: Loading file URL: file:/Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function/hello-1.0-SNAPSHOT.jar
[16/05/2020 12:52:21] Worker failed to function id 3d8382a0-0746-4c93-af63-cd6ec12aa2f9.
[16/05/2020 12:52:21] Result: Failure
[16/05/2020 12:52:21] 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')
[16/05/2020 12:52:21] 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')
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider.addUrlToSystemClassLoader(DefaultClassLoaderProvider.java:72)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider.addUrl(DefaultClassLoaderProvider.java:62)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.addSearchPathsToClassLoader(JavaFunctionBroker.java:64)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.loadMethod(JavaFunctionBroker.java:33)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.handler.FunctionLoadRequestHandler.execute(FunctionLoadRequestHandler.java:27)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.handler.FunctionLoadRequestHandler.execute(FunctionLoadRequestHandler.java:9)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[16/05/2020 12:52:21]   at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[16/05/2020 12:52:21]   at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[16/05/2020 12:52:21]   at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[16/05/2020 12:52:21]   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[16/05/2020 12:52:21]   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[16/05/2020 12:52:21]   at java.base/java.lang.Thread.run(Thread.java:834)
[16/05/2020 12:52:21] .
[16/05/2020 12:52:21] Found the following functions:
[16/05/2020 12:52:21] Host.Functions.hello
[16/05/2020 12:52:21]
[16/05/2020 12:52:21] Initializing function HTTP routes
[16/05/2020 12:52:21] Mapped function route 'api/hello' [GET,POST] to 'hello'
[16/05/2020 12:52:21]
[16/05/2020 12:52:21] Host initialized (151ms)
[16/05/2020 12:52:21] Host started (159ms)
[16/05/2020 12:52:21] Job host started

Http Functions:

    hello: [GET,POST] http://localhost:7071/api/hello

Hosting environment: Production
Content root path: /Users/pomverte/git/hello-spring-function-azure/target/azure-functions/hvle-spring-function
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[16/05/2020 12:52:26] Host lock lease acquired by instance ID '000000000000000000000000B32B4E5F'.
$ curl -v http://localhost:7071/api/hello -d "{\"name\":\"Azure\"}"
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 7071 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 7071 (#0)
> POST /api/hello HTTP/1.1
> Host: localhost:7071
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 16
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 16 out of 16 bytes
< HTTP/1.1 500 Internal Server Error
< Date: Sat, 16 May 2020 12:53:42 GMT
< Server: Kestrel
< Content-Length: 0
<
* Connection #0 to host localhost left intact
[16/05/2020 12:52:56] Executing HTTP request: {
[16/05/2020 12:52:56]   "requestId": "83837a81-1301-4919-b824-6012669f345b",
[16/05/2020 12:52:56]   "method": "POST",
[16/05/2020 12:52:56]   "uri": "/api/hello"
[16/05/2020 12:52:56] }
[16/05/2020 12:52:56] Executing 'Functions.hello' (Reason='This function was programmatically called via the host APIs.', Id=1d3e5579-d13a-41dc-b12d-c223915ec43f)
[16/05/2020 12:52:56] Executed 'Functions.hello' (Failed, Id=1d3e5579-d13a-41dc-b12d-c223915ec43f)
[16/05/2020 12:52:56] System.Private.CoreLib: Exception while executing function: Functions.hello. System.Private.CoreLib: Result: Failure
[16/05/2020 12:52:56] 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')
[16/05/2020 12:52:56] 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')
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider.addUrlToSystemClassLoader(DefaultClassLoaderProvider.java:72)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.reflect.DefaultClassLoaderProvider.addUrl(DefaultClassLoaderProvider.java:62)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.addSearchPathsToClassLoader(JavaFunctionBroker.java:64)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.loadMethod(JavaFunctionBroker.java:33)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.handler.FunctionLoadRequestHandler.execute(FunctionLoadRequestHandler.java:27)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.handler.FunctionLoadRequestHandler.execute(FunctionLoadRequestHandler.java:9)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[16/05/2020 12:52:56]   at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[16/05/2020 12:52:56]   at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[16/05/2020 12:52:56]   at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[16/05/2020 12:52:56]   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[16/05/2020 12:52:56]   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[16/05/2020 12:52:56]   at java.base/java.lang.Thread.run(Thread.java:834)
[16/05/2020 12:52:56] .
[16/05/2020 12:52:56] Executed HTTP request: {
[16/05/2020 12:52:56]   "requestId": "83837a81-1301-4919-b824-6012669f345b",
[16/05/2020 12:52:56]   "method": "POST",
[16/05/2020 12:52:56]   "uri": "/api/hello",
[16/05/2020 12:52:56]   "identities": [
[16/05/2020 12:52:56]     {
[16/05/2020 12:52:56]       "type": "WebJobsAuthLevel",
[16/05/2020 12:52:56]       "level": "Admin"
[16/05/2020 12:52:56]     }
[16/05/2020 12:52:56]   ],
[16/05/2020 12:52:56]   "status": 500,
[16/05/2020 12:52:56]   "duration": 256
[16/05/2020 12:52:56] }

Expected/desired behavior

To receive a response with Greeting user name: Azure

OS and Version?

macOS Mojave 10.14.6 (18G4032)

Versions

$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)

Mention any other details that might be useful


Thanks! We'll be in touch soon.

jdubois commented 4 years ago

It is because you are not using Java 8, which is the only currently supported version.

Duplicate of #4

I need to check as Java 11 should be supported now, in that case I'll update the sample

jdubois commented 4 years ago

@pomverte this is in fact one of the questions I'm expecting to have at https://mybuild.microsoft.com/sessions/95be4bac-0ad1-4dee-a1b3-c767c260dd17?source=sessions -> you are much welcome to join us and ask it, obviously!