Проблема проверки подлинности хранилища Azure

Я пытаюсь пройти аутентификацию в Azure Vault. Я все время получаю эту ошибку:

java.lang.NoClassDefFoundError: не удалось инициализировать класс response.netty.http.client.HttpClientSecure

Вот мой код для лазерной аутентификации:

      public class AzureKeyVaultAuthenticator {

    /**
     * Do certificate based authentication using your PFX file.
     *
     * @param clientId
     *            Also known as applicationId which is received as a part of the app creation process.
     * @param tenantId
     *            Also known as directoryId which is received as a part of the app creation process.
     * @param pathPfx
     *            Path to your PFX certificate.
     * @param pfxPassword
     *            Password to your PFX certificate, this can be empty if that's the value given when it was created.
     */
    public TokenCredential getTokenCredential(String clientId, String tenantId, String pathPfx, String pfxPassword) {

        TokenCredential credential = new ClientCertificateCredentialBuilder()
                .clientId(clientId)
                .tenantId(tenantId)
                .pfxCertificate(pathPfx, pfxPassword)
                .build();

        return credential;
    }

    /**
     * Find the vault you want to operate on by keyVaultName.
     *
     * @param credential
     *            Credential to authenticate a {@link KeyVaultManager} with.
     * @param resourceGroupName
     *            The name of the resource group your Key Vault is a part of.
     * @param vaultBaseUrl
     *            The URL that identifies your Key Vault.
     * @return A {@link Vault} object representing your Key Vault.
     */
    public Vault getVault(TokenCredential credential, String resourceGroupName, String vaultBaseUrl) {

        AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
        KeyVaultManager manager = KeyVaultManager.authenticate(credential, profile);

        Optional<Vault> optional = manager
                .vaults()
                .listByResourceGroup(resourceGroupName)
                .stream()
                .filter(vault -> vaultBaseUrl.equals(vault.vaultUri()))
                .findFirst();
        if (optional.isPresent()) {
            return optional.get();
        }
        return null;
    }
}

Я думаю, это связано с совместимостью с версиями зависимостей. Я использую версии, указанные в bom-файле официального GitHub для Azure SDK.

Это часть моего файла pom

      <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-administration</artifactId>
    <version>4.0.3</version>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-certificates</artifactId>
    <version>4.2.3</version>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-jca</artifactId>
    <version>2.0.0</version>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-keys</artifactId>
    <version>4.3.3</version>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-secrets</artifactId>
    <version>4.3.3</version>
</dependency>

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core-management</artifactId>
    <version>1.4.1</version>
</dependency>

<dependency>
    <groupId>com.azure.resourcemanager</groupId>
    <artifactId>azure-resourcemanager-resources</artifactId>
    <version>2.8.0</version>
</dependency>

<dependency>
    <groupId>com.azure.resourcemanager</groupId>
    <artifactId>azure-resourcemanager-keyvault</artifactId>
    <version>2.8.0</version>
</dependency>


<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-keys</artifactId>
    <version>4.3.2</version>
</dependency>

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>msal4j</artifactId>
    <version>1.11.0</version>
</dependency>

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-administration</artifactId>
    <version>4.0.3</version>
</dependency>

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-identity</artifactId>
    <version>1.3.6</version>
</dependency>

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-core</artifactId>
    <version>1.20.0</version>
</dependency>

<!-- Reactor -->
<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.4.9</version>
</dependency>
<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-test</artifactId>
    <version>3.4.9</version>
</dependency>
<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-tools</artifactId>
    <version>3.4.9</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.addons</groupId>
    <artifactId>reactor-extra</artifactId>
    <version>3.4.4</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.addons</groupId>
    <artifactId>reactor-adapter</artifactId>
    <version>3.4.4</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.netty</groupId>
    <artifactId>reactor-netty</artifactId>
    <version>1.0.10</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.netty</groupId>
    <artifactId>reactor-netty-core</artifactId>
    <version>1.0.10</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.netty</groupId>
    <artifactId>reactor-netty-http</artifactId>
    <version>1.0.10</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.netty</groupId>
    <artifactId>reactor-netty-http-brave</artifactId>
    <version>1.0.10</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.addons</groupId>
    <artifactId>reactor-pool</artifactId>
    <version>0.2.6</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.kafka</groupId>
    <artifactId>reactor-kafka</artifactId>
    <version>1.3.5</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.rabbitmq</groupId>
    <artifactId>reactor-rabbitmq</artifactId>
    <version>1.5.3</version>
</dependency>
<dependency>
    <groupId>io.projectreactor.kotlin</groupId>
    <artifactId>reactor-kotlin-extensions</artifactId>
    <version>1.1.4</version>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-handler</artifactId>
    <version>4.1.67.Final</version>
</dependency>

<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>8.20</version>
</dependency>

Я обновил Spring до 2.4.0

1 ответ

Спасибо мистеру Константину Иванову . Размещение вашего предложения в качестве ответа, чтобы помочь другим членам сообщества.

Чтобы решить эту проблему java.lang.NoClassDefFoundError: Could not initialize class reactor.netty.http.client.HttpClientSecure, вы можете попробовать добавить последнюю версию netty boringssl:

      <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
            <version>2.0.43.Final</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

pom.xml

      <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-storage-blob</artifactId>
            <version>12.14.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.azure</groupId>
                    <artifactId>azure-core-http-netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.azure.resourcemanager</groupId>
            <artifactId>azure-resourcemanager</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-identity</artifactId>
            <version>1.3.6</version>
            <exclusions>
                <exclusion>
                    <groupId>com.azure</groupId>
                    <artifactId>azure-core-http-netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-core-http-netty</artifactId>
            <version>1.11.0</version>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-core</artifactId>
            <version>3.4.10</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>
        <dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty</artifactId>
            <version>1.0.11</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
            <version>2.0.43.Final</version><!--$NO-MVN-MAN-VER$ -->
        </dependency>

Вы можете обратиться к [ОШИБКА] Не удалось инициализировать класс response.netty.http.client.HttpClientSecure и SSL для настройки производительности.

Другие вопросы по тегам