0

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>
dersu
  • 189
  • 1
  • 7
  • I am not familiar with the Confluence plugin API and the restrictions around their builds, but noticed that you were facing issues with the 1.7.25 version of SLF4J. I would recommend trying [1.7.36](https://mvnrepository.com/artifact/org.slf4j/slf4j-api/1.7.36), maybe it will solve your issue. – Esta Nagy Jul 03 '22 at 11:00
  • 1.7.36 produces the same behavior – dersu Aug 02 '22 at 13:48

1 Answers1

0

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

Venkatesan
  • 3,748
  • 1
  • 3
  • 15