Azure Keyvault library to Atlassian Confluence plugin pom.xml

144 Views Asked by At

I am trying to combine these 2 tutorials - Confluence Hello World Macro & Azure keyvault quick start: https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-confluence-hello-world-macro/

https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-java?tabs=azure-cli

After having added the 2 Azure dependencies to the pom.xml of the maven project and running atlas-mvn clean package I receive an error message about 3 banned dependencies. I looked for the newest Azure packages at the maven portal. Then it was reduced to one.

Found Banned Dependency: org.slf4j:slf4j-api:jar:1.7.25

Then I added added exclusions to the dependency section:

This resulted that the build ran successfully, however, the Confluence plugin produces a runtime error: java.lang.NoClassDefFoundError Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger at com.azure.security.keyvault.secrets.SecretClientBuilder.(SecretClientBuilder.java:110)

Can you please help, how can I achieve this?

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-security-keyvault-secrets</artifactId>
    <version>4.3.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-identity</artifactId>
    <version>1.4.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

1

There are 1 best solutions below

3
Venkatesan On

error: java.lang.NoClassDefFoundError Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger at com.azure.security.keyvault.secrets.SecretClientBuilder.(SecretClientBuilder.java:110)

The above error indicates that JVM is not able to found org/slf4j/Logger class in your application's path.The simplest reason for this error is the missing Slf4j.jar file.

  • If the problem is caused due to the missing slf4j.jar file then you can fix it by adding a relevant version of slf4j.jar into your path.
  • Use the latest version of the jar in which version of the JAR file you should add will depend upon the application.

In Maven , you can also add the following dependency in your pom.xml file to download sl4j.jar

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.36</version>
</dependency>

Reference: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory - Stack Overflow