Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.25k stars 1.93k forks source link

[QUERY] Key vault NoSuchMethodError with Spring Cloud Function / Azure function #19779

Closed Eric-fc closed 3 years ago

Eric-fc commented 3 years ago

Describe the bug Getting NoSuchMethodError for (io.netty.handler.ssl.SslProvider.isAlpnSupported) when getting secret from key vault, same code working as expected when running as standalone spring boot application.

Exception or Stack Trace [2021-03-10T22:31:21.012Z] Manifest-Version: 1.0 [2021-03-10T22:31:21.012Z] Implementation-Title: Azure Functions Java Worker [2021-03-10T22:31:21.012Z] Implementation-Version: 1.8.1 [2021-03-10T22:31:21.012Z] Built-By: appveyor [2021-03-10T22:31:21.012Z] Created-By: Apache Maven 3.6.0 [2021-03-10T22:31:21.012Z] Build-Jdk: 1.8.0162 [2021-03-10T22:31:21.012Z] Main-Class: com.microsoft.azure.functions.worker.Application [2021-03-10T22:31:21.012Z] Implementation-Vendor: Microsoft Azure [2021-03-10T22:31:21.020Z] 16:31:21.020 [pool-2-thread-1] INFO org.springframework.cloud.function.utils.FunctionClassUtils - Searching for start class in manifest: jar:file:/C:/work/Repositories/personal.eric.li/acord-feed-processor/target/azure-functions/FC-AZ-FA-USC-Dev-acord1/acord-feed-processor-0.0.1-SNAPSHOT.jar!/META-INF/MANIFEST.MF [2021-03-10T22:31:21.021Z] Manifest-Version: 1.0 [2021-03-10T22:31:21.021Z] Implementation-Title: acord-feed-processor [2021-03-10T22:31:21.021Z] Implementation-Version: 0.0.1-SNAPSHOT [2021-03-10T22:31:21.021Z] Build-Jdk-Spec: 1.8 [2021-03-10T22:31:21.021Z] Created-By: Maven Jar Plugin 3.2.0 [2021-03-10T22:31:21.021Z] Main-Class: com.fc.acordfeedprocessor.AcordFeedProcessorApplication [2021-03-10T22:31:21.024Z] 16:31:21.023 [pool-2-thread-1] INFO org.springframework.cloud.function.utils.FunctionClassUtils - Loaded Start Class: class com.fc.acordfeedprocessor.AcordFeedProcessorApplication [2021-03-10T22:31:21.024Z] 16:31:21.024 [pool-2-thread-1] INFO org.springframework.cloud.function.utils.FunctionClassUtils - Main class: class com.fc.acordfeedprocessor.AcordFeedProcessorApplication [2021-03-10T22:31:21.025Z] 16:31:21.024 [pool-2-thread-1] INFO org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer - Initializing: class com.fc.acordfeedprocessor.AcordFeedProcessorApplication [2021-03-10T22:31:21.025Z] Java HTTP trigger processed a request. [2021-03-10T22:31:21.026Z] Handler processing a request for: uppercase [2021-03-10T22:31:21.553Z] . ____ [2021-03-10T22:31:21.554Z] /\ / __' () _ \ \ \ \ [2021-03-10T22:31:21.554Z] ( ( )__ | ' | '| | ' \/ _` | \ \ \ \ [2021-03-10T22:31:21.554Z] \/ _)| |)| | | | | || (| | ) ) ) ) [2021-03-10T22:31:21.554Z] ' |__| .|| ||| |\, | / / / / [2021-03-10T22:31:21.554Z] =========|_|==============|__/=//// [2021-03-10T22:31:21.554Z] :: Spring Boot :: (v2.4.3) [2021-03-10T22:31:21.761Z] 2021-03-10 16:31:21.759 INFO 27124 --- [pool-2-thread-1] o.s.boot.SpringApplication : Starting application using Java 1.8.0_261 on FC-877T433 with PID 27124 (C:\work\Repositories\personal.eric.li\acord-feed-processor\target\azure-functions\FC-AZ-FA-USC-Dev-acord1\lib\spring-cloud-function-web-3.1.0.BUILD-SNAPSHOT.jar started by xiang.li in C:\work\Repositories\personal.eric.li\acord-feed-processor\target\azure-functions\FC-AZ-FA-USC-Dev-acord1) [2021-03-10T22:31:21.762Z] 2021-03-10 16:31:21.760 INFO 27124 --- [pool-2-thread-1] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default [2021-03-10T22:31:22.373Z] 2021-03-10 16:31:22.372 INFO 27124 --- [pool-2-thread-1] o.s.boot.SpringApplication : Started application in 1.076 seconds (JVM running for 13.572) [2021-03-10T22:31:22.377Z] 2021-03-10 16:31:22.376 INFO 27124 --- [pool-2-thread-1] o.s.c.f.c.c.SimpleFunctionRegistry : Looking up function 'function' with acceptedOutputTypes: [] [2021-03-10T22:31:22.380Z] 2021-03-10 16:31:22.379 INFO 27124 --- [pool-2-thread-1] o.s.c.f.c.c.SimpleFunctionRegistry : Looking up function 'consumer' with acceptedOutputTypes: [] [2021-03-10T22:31:22.380Z] 2021-03-10 16:31:22.380 INFO 27124 --- [pool-2-thread-1] o.s.c.f.c.c.SimpleFunctionRegistry : Looking up function 'supplier' with acceptedOutputTypes: [] [2021-03-10T22:31:22.381Z] 2021-03-10 16:31:22.381 INFO 27124 --- [pool-2-thread-1] o.s.c.f.c.c.SimpleFunctionRegistry : Looking up function 'uppercase' with acceptedOutputTypes: [] [2021-03-10T22:31:22.391Z] Handler processing a request for: uppercase [2021-03-10T22:31:22.578Z] com.azure.identity.ClientSecretCredential@47b77d27 [2021-03-10T22:31:22.608Z] 2021-03-10 16:31:22.607 INFO 27124 --- [pool-2-thread-1] c.a.s.k.secrets.SecretAsyncClient : Retrieving secret - connectionpass [2021-03-10T22:31:22.716Z] Executed 'Functions.uppercase' (Failed, Id=92ab19be-8afb-409b-ba1d-6ed563d44c01, Duration=1800ms) [2021-03-10T22:31:22.716Z] System.Private.CoreLib: Exception while executing function: Functions.uppercase. System.Private.CoreLib: Result: Failure Exception: NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z Stack: java.lang.reflect.InvocationTargetException [2021-03-10T22:31:22.716Z] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [2021-03-10T22:31:22.716Z] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [2021-03-10T22:31:22.716Z] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [2021-03-10T22:31:22.716Z] at java.lang.reflect.Method.invoke(Method.java:498) [2021-03-10T22:31:22.716Z] at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:22) [2021-03-10T22:31:22.716Z] at com.microsoft.azure.functions.worker.broker.JavaMethodExecutorImpl.execute(JavaMethodExecutorImpl.java:54) [2021-03-10T22:31:22.716Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:57) [2021-03-10T22:31:22.716Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33) [2021-03-10T22:31:22.716Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10) [2021-03-10T22:31:22.717Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45) [2021-03-10T22:31:22.717Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92) [2021-03-10T22:31:22.717Z] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [2021-03-10T22:31:22.717Z] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [2021-03-10T22:31:22.717Z] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [2021-03-10T22:31:22.717Z] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [2021-03-10T22:31:22.717Z] at java.lang.Thread.run(Thread.java:748) [2021-03-10T22:31:22.717Z] Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z [2021-03-10T22:31:22.717Z] at org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler.handleRequest(AzureSpringBootRequestHandler.java:99) [2021-03-10T22:31:22.717Z] at com.fc.acordfeedprocessor.function.AcordFeedProcessorHandler.execute(AcordFeedProcessorHandler.java:30) [2021-03-10T22:31:22.717Z] ... 16 more [2021-03-10T22:31:22.717Z] Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z [2021-03-10T22:31:22.717Z] at org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler.handleRequest(AzureSpringBootRequestHandler.java:99) [2021-03-10T22:31:22.717Z] at org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler.handleRequest(AzureSpringBootRequestHandler.java:83) [2021-03-10T22:31:22.717Z] ... 17 more [2021-03-10T22:31:22.717Z] Caused by: java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z [2021-03-10T22:31:22.717Z] at reactor.netty.http.client.HttpClientSecure.(HttpClientSecure.java:72) [2021-03-10T22:31:22.717Z] at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:217) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:76) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.MonoRetryWhen.subscribeOrReturn(MonoRetryWhen.java:46) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57) [2021-03-10T22:31:22.718Z] at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:269) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.Mono.subscribe(Mono.java:4046) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.Mono.block(Mono.java:1702) [2021-03-10T22:31:22.718Z] at com.azure.security.keyvault.secrets.SecretClient.getSecretWithResponse(SecretClient.java:173) [2021-03-10T22:31:22.718Z] at com.azure.security.keyvault.secrets.SecretClient.getSecret(SecretClient.java:152) [2021-03-10T22:31:22.718Z] at com.fc.acordfeedprocessor.AcordFeedProcessorApplication.getKVSecret(AcordFeedProcessorApplication.java:128) [2021-03-10T22:31:22.718Z] at com.fc.acordfeedprocessor.AcordFeedProcessorApplication.lambda$uppercase$1(AcordFeedProcessorApplication.java:64) [2021-03-10T22:31:22.718Z] at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.invokeFunction(SimpleFunctionRegistry.java:503) [2021-03-10T22:31:22.718Z] at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.lambda$doApply$3(SimpleFunctionRegistry.java:570) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:113) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:127) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2397) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:169) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:169) [2021-03-10T22:31:22.718Z] at reactor.core.publisher.BlockingIterable$SubscriberIterator.onSubscribe(BlockingIterable.java:225) [2021-03-10T22:31:22.719Z] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) [2021-03-10T22:31:22.719Z] at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96) [2021-03-10T22:31:22.719Z] at reactor.core.publisher.FluxJust.subscribe(FluxJust.java:68) [2021-03-10T22:31:22.719Z] at reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62) [2021-03-10T22:31:22.719Z] at reactor.core.publisher.BlockingIterable.iterator(BlockingIterable.java:82) [2021-03-10T22:31:22.719Z] at org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer.result(AbstractSpringFunctionAdapterInitializer.java:209) [2021-03-10T22:31:22.719Z] at org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler.handleRequest(AzureSpringBootRequestHandler.java:88) [2021-03-10T22:31:22.719Z] ... 18 more [2021-03-10T22:31:22.719Z] .

To Reproduce Create spring cloud function and add below dependencies, run the code snippets below as azure function.

POM:

<?xml version="1.0" encoding="UTF-8"?>

org.springframework.boot spring-boot-starter-parent 2.4.3
<properties>
    <java.version>8</java.version>
    <functionAppName>FC-AZ-FA-USC-Dev-acord1</functionAppName>
    <functionResourceGroup>fsyed-devtest</functionResourceGroup>
    <functionAppRegion>centralus</functionAppRegion>

    <stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
    <azure.functions.java.library.version>1.4.0</azure.functions.java.library.version>
    <azure.functions.maven.plugin.version>1.9.0</azure.functions.maven.plugin.version>
    <start-class>com.fc.acordfeedprocessor.AcordFeedProcessorApplication</start-class>
    <wrapper.version>1.0.26.RELEASE</wrapper.version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-function-adapter-azure</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-function-web</artifactId>
        <scope>provided</scope>
    </dependency>

    <!--Azure Key Vault-->
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-security-keyvault-secrets</artifactId>
        <version>4.2.5</version>
    </dependency>

    <!-- Azure Identity -->
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-identity</artifactId>
        <version>1.2.3</version>
    </dependency>

    <!--Utilities -->

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>20.0</version>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-function-dependencies</artifactId>
            <version>3.1.0.BUILD-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
            <version>${azure.functions.java.library.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-webapp-maven-plugin</artifactId>
                <version>1.12.0</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/productGenerated/productSwagger/</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${basedir}</directory>
                            <includes>
                                <include>obj/**</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>${basedir}</directory>
                            <includes>
                                <include>extensions.csproj</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-functions-maven-plugin</artifactId>
                <version>${azure.functions.maven.plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/productGenerated/productSwagger/</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${stagingDirectory}/lib</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <excludeArtifactIds>azure-functions-java-library</excludeArtifactIds>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-functions-maven-plugin</artifactId>
            <configuration>
                <resourceGroup>${functionResourceGroup}</resourceGroup>
                <appName>${functionAppName}</appName>
                <region>${functionAppRegion}</region>
                <appSettings>
                    <!-- Run Azure Function from package file by default -->
                    <property>
                        <name>WEBSITE_RUN_FROM_PACKAGE</name>
                        <value>1</value>
                    </property>
                    <property>
                        <name>FUNCTIONS_EXTENSION_VERSION</name>
                        <value>~2</value>
                    </property>
                    <property>
                        <name>FUNCTIONS_WORKER_RUNTIME</name>
                        <value>java</value>
                    </property>
                </appSettings>
            </configuration>
            <executions>
                <execution>
                    <id>package-functions</id>
                    <goals>
                        <goal>package</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <overwrite>true</overwrite>
                        <outputDirectory>
                            ${stagingDirectory}
                        </outputDirectory>
                        <resources>
                            <resource>
                                <directory>${project.basedir}/src/main/azure
                                </directory>
                                <includes>
                                    <include>**</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.boot.experimental</groupId>
                    <artifactId>spring-boot-thin-layout</artifactId>
                    <version>${wrapper.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/libs-snapshot-local</url>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/libs-milestone-local</url>
    </repository>
    <repository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>https://repo.spring.io/release</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/libs-snapshot-local</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/libs-milestone-local</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-releases</id>
        <name>Spring Releases</name>
        <url>https://repo.spring.io/libs-release-local</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

Code Snippet Add the code snippet that causes the issue. ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder() .clientId("") .clientSecret("") .tenantId("") .build();

    SecretClient secretClient = new SecretClientBuilder()
            .vaultUrl("https://vaultname.vault.azure.net")
            .credential(clientSecretCredential)
            .buildClient();

    KeyVaultSecret secret = secretClient.getSecret("connectionpass");

Expected behavior A clear and concise description of what you expected to happen. Secret being retrieved as expected

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

Additional context Same code works properly when run applicaiton as standalone spring boot app, once it's being run as azure function, getting this exception.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

joshfree commented 3 years ago

Thanks for the detailed github issue, @Eric-fc. @anuchandy can you please help @Eric-fc resolve this dependency mismatch?

/cc @stliu as fyi

anuchandy commented 3 years ago

@Eric-fc, This seems due to the dependency conflict resulting from function loading the worker Jar then App Jar; this is the default behavior; to reverse the loading order you'll need to define and set the application variable FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS to 1.

Screen Shot 2021-03-17 at 4 52 37 PM

saikirangit commented 3 years ago

How do you set FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS for local run of functions??

I tried this in local settings json but still have same error

{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "", "FUNCTIONS_WORKER_RUNTIME": "java", "AzureWebJobsDashboard": "", "FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS": 1 }, "Host": { "LocalHttpPort": 7072 } }

anuchandy commented 3 years ago

The env variable FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS seems no effect on local run but only on real azure functions.

Created an issue in Function-Worker repo to triage this: https://github.com/Azure/azure-functions-java-worker/issues/425

\cc @amamounelsayed

anuchandy commented 3 years ago

Hi @saikirangit could you try the resolution that Ahmed mentioned in the functions-java-worker ticket? If you still run into conflict issue, lets follow up in the same functions-java-worker ticket.

anuchandy commented 3 years ago

Closing this issue, like the function team suggested, upgrading the core tool unblocked local run. the FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS is confirmed to work both locally and in functions.