Azure-sdk-for-java: NoClassDefFoundError in azure-spring-boot-starter-keyvault-secrets:3.0.0 about reactor

Created on 8 Jan 2021  路  8Comments  路  Source: Azure/azure-sdk-for-java

Describe the bug
I am using following in pom for spring boot project:

<!-- https://mvnrepository.com/artifact/com.azure.spring/azure-spring-boot-starter-keyvault-secrets -->
        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>azure-spring-boot-starter-keyvault-secrets</artifactId>
            <version>3.0.0</version>
        </dependency>

and accessing secret using property value annotation.
All other properties are defined such as client secret,id, tenant id, vault url but after running getting NoClassDefError for
reactor/util/retry/Retry

Exception or Stack Trace
Add the exception log and stack trace if available
java.lang.NoClassDefFoundError: reactor/util/retry/Retry at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:329) at reactor.core.publisher.MonoFlatMapMany.subscribe(MonoFlatMapMany.java:49) at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58) at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74) at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59) at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59) at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60) at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60) at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60) at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44) at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53) at reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55) at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60) at reactor.core.publisher.MonoDoOnEach.subscribe(MonoDoOnEach.java:44) at reactor.core.publisher.MonoSubscriberContext.subscribe(MonoSubscriberContext.java:47) at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60) at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:70) at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61) at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74) at reactor.core.publisher.FluxSourceMonoFuseable.subscribe(FluxSourceMonoFuseable.java:38) at reactor.core.publisher.FluxMapFuseable.subscribe(FluxMapFuseable.java:63) at reactor.core.publisher.Flux.blockLast(Flux.java:2051) at com.azure.core.util.paging.ContinuablePagedByIteratorBase.requestPage(ContinuablePagedByIteratorBase.java:94) at com.azure.core.util.paging.ContinuablePagedByPageIterable$ContinuablePagedByPageIterator.<init>(ContinuablePagedByPageIterable.java:49) at com.azure.core.util.paging.ContinuablePagedByPageIterable.iterator(ContinuablePagedByPageIterable.java:37) at java.lang.Iterable.spliterator(Iterable.java:101) at com.azure.spring.keyvault.KeyVaultOperation.lambda$refreshProperties$2(KeyVaultOperation.java:142) at java.util.Optional.map(Optional.java:215) at com.azure.spring.keyvault.KeyVaultOperation.refreshProperties(KeyVaultOperation.java:142) at com.azure.spring.keyvault.KeyVaultOperation.<init>(KeyVaultOperation.java:80) at com.azure.spring.keyvault.KeyVaultEnvironmentPostProcessorHelper.addKeyVaultPropertySource(KeyVaultEnvironmentPostProcessorHelper.java:101) at com.azure.spring.keyvault.KeyVaultEnvironmentPostProcessor.postProcessEnvironment(KeyVaultEnvironmentPostProcessor.java:47) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:185) at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:171) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338) at org.springframework.boot.SpringApplication.run(SpringApplication.java:297)
To Reproduce
Steps to reproduce the behavior:

Just add mentioned dependency with proper application properties and start application.

Code Snippet
Add the code snippet that causes the issue.

Expected behavior
A clear and concise description of what you expected to happen.
Value from keyvault is expected
Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: MacOS , Catalina
  • IDE : Intellij
  • Version of the Library used : 3.0.0, Jdk 8

Additional context
Add any other context about the problem here.

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

  • [x] Bug Description Added
  • [ ] Repro Steps Added
  • [ ] Setup information Added
Client azure-spring azure-spring-keyvault customer-reported question

Most helpful comment

Hi, @rishabhgpt, @FireDrunk,

Please upgrade spring-boot-starter-parent's version. For azure-spring-boot-starter-keyvault-secrets:3.0.0, the min version supported is spring-boot-starter-parent:2.2.11.RELEASE. So you can use:

  1. 2.2.11.RELEASE -> 2.2.12.RELEASE
  2. 2.3.0.RELEASE -> 2.3.7.RELEASE

All 8 comments

@yiliuTo Should the azure-security-keyvault-secrets version be 4.2.3 according to the latest dependency version here ?

@samvaity

Should the azure-security-keyvault-secrets version be 4.2.3

Yes, I think so.

Refs: https://github.com/Azure/azure-sdk-for-java/blob/azure-spring-boot_3.0.0/sdk/spring/azure-spring-boot/pom.xml#L168

Hi, @rishabhgpt .
Could you please share your pom file?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>kvault</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>kvault</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-keyvault-secrets-spring-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

I have almost the same issue, but with the instantiation of the custom Netty provider:

Caused by: java.lang.NoClassDefFoundError: reactor/netty/tcp/ProxyProvider$TypeSpec 
    at com.azure.core.http.netty.NettyAsyncHttpClientBuilder.lambda$build$7(NettyAsyncHttpClientBuilder.java:139) ~[azure-core-http-netty-1.7.0.jar:na]

Using versions:
Azure Core: 1.11.0
Azure Keyvault Secrets: 4.2.3
Azure Core HTTP: 1.7.0

I think the errors are related, but I'm not using the Azure / Microsoft spring-boot-starter dependencies.

EDIT: Issue was -fixed- with downgrading Core HTTP (back) to 1.5.3.
That only fixed the compile time issue, runtime still throws:

Caused by: java.lang.NoClassDefFoundError: reactor/netty/channel/BootstrapHandlers

Hi, @rishabhgpt, @FireDrunk,

Please upgrade spring-boot-starter-parent's version. For azure-spring-boot-starter-keyvault-secrets:3.0.0, the min version supported is spring-boot-starter-parent:2.2.11.RELEASE. So you can use:

  1. 2.2.11.RELEASE -> 2.2.12.RELEASE
  2. 2.3.0.RELEASE -> 2.3.7.RELEASE

Issue is resolved. thanks for the help. Would be helpful if we can track dependencies b/w spring boot versions and sdk versions somewhere. if already done please share a link.

@rishabhgpt , Here is the link: https://github.com/Azure/azure-sdk-for-java/wiki/Spring-Boot-Dependency-Mapping#version-schema-in-azure-sdk-for-java-repo

Was this page helpful?
0 / 5 - 0 ratings