I am developing a jar file to upload in an application which will utilise it to connect to Azure key vault and retrieve credential to further run some actions on servers. I am using Maven and is stuck on this error:
java.lang.NoClassDefFoundError: reactor/netty/transport/ClientTransport
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
This is the code section:
ClientCertificateCredential clientCertificateCredential = new ClientCertificateCredentialBuilder()
.tenantId(TenantID)
.clientId(ClientID)
.pfxCertificate(CertificatePath, CertificatePassword)
.build();
SecretClient secretClient = new SecretClientBuilder()
.vaultUrl(keyVaultUrl)
.credential(clientCertificateCredential)
.buildClient();
I have tried quite a few versions of dependencies but still not able to resolve it as i am new to this. Stuck on it for a few days now. This is how the dependency section looks like:
<!--<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.26.0</version>
</dependency>-->
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-security-keyvault-secrets</artifactId>
<version>4.2.3</version>
</dependency>
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.14.0</version>
</dependency>-->
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.4.10</version>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>1.0.11</version>
</dependency>
I have already tried a few versions of the dependencies but i am new to this and not able to figure out.
Update: I added the azure bom in pom file, still getting the error slightly changed though:
java.lang.NoClassDefFoundError: reactor/netty/transport/ClientTransport at com.azure.core.http.netty.NettyAsyncHttpClientBuilder.build(NettyAsyncHttpClientBuilder.java:141) at com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:19) at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:67) at com.azure.core.http.HttpClient.createDefault(HttpClient.java:50) at com.azure.core.http.HttpClient.createDefault(HttpClient.java:40) at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:73) at com.azure.security.keyvault.secrets.SecretClientBuilder.buildAsyncClient(SecretClientBuilder.java:225) at com.azure.security.keyvault.secrets.SecretClientBuilder.buildClient(SecretClientBuilder.java:147) at com.snc.discovery.CredentialResolver.resolve(CredentialResolver.java:177) at com.service_now.mid.services.CredentialResolverProxy.resolveWithSemaphore(CredentialResolverProxy.java:392) at com.service_now.mid.services.CredentialResolverProxy.lambda$resolveFromVault$1(CredentialResolverProxy.java:329) at java.base/java.util.Optional.orElseGet(Optional.java:369) at com.service_now.mid.services.CredentialResolverProxy.resolveFromVault(CredentialResolverProxy.java:329) at com.service_now.mid.services.CredentialResolverProxy.lambda$resolve$0(CredentialResolverProxy.java:313) at java.base/java.util.Optional.orElseGet(Optional.java:369) at com.service_now.mid.services.CredentialResolverProxy.resolve(CredentialResolverProxy.java:313) at com.service_now.mid.creds.provider.standard.HighSecurityCredential.callResolver(HighSecurityCredential.java:55) at com.service_now.mid.creds.provider.standard.HighSecurityCredential.getAttribute(HighSecurityCredential.java:177) at com.snc.automation_common.integration.creds.Credential.isMidServerServiceAccount(Credential.java:151) at com.service_now.mid.win.powershell.api.APowershellSession.testCredential(APowershellSession.java:416) at com.service_now.mid.win.powershell.api.PowerShellConnectionFactory.getConnection(PowerShellConnectionFactory.java:60) at com.service_now.mid.win.powershell.api.PowerShellConnectionFactory.getConnection(PowerShellConnectionFactory.java:22) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnectionUseOneCred(AKeyedConnectionFactory.java:266) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnectionIterateOverCreds(AKeyedConnectionFactory.java:208) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnection(AKeyedConnectionFactory.java:158) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnection(AKeyedConnectionFactory.java:145) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnection(AKeyedConnectionFactory.java:133) at com.service_now.mid.pipeline.command.TestCredentialCommandImpl.executeRawCommand(TestCredentialCommandImpl.java:126) at com.snc.core_automation_common.pipeline.ACommand.execute(ACommand.java:114) at com.service_now.mid.probe.CommandPipeline.probe(CommandPipeline.java:67) at com.service_now.mid.probe.AProbe.process(AProbe.java:155) at com.service_now.mid.queue_worker.AWorker.runWorker(AWorker.java:131) at com.service_now.mid.queue_worker.AWorkerThread.run(AWorkerThread.java:20) at com.service_now.mid.threadpool.ResourceUserQueue$RunnableProxy.run(ResourceUserQueue.java:640) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)
I have been able to resolve the error by excluding
azure-core-http-nettyfrom the azure dependencies (azure-identity and azure-security-keyvault-secrets) and addingazure-core-http-okhttpartifact. Referenced this thread: https://github.com/Azure/azure-sdk-for-java/issues/19041