April 27, 2020
Estimated Post Reading Time ~

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;Jcr2davRepositoryFactory

I was getting the below exception while connecting to the AEM JCR repository through Java API(JCR webdav) using Jcr2davRepositoryFactory.

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.format(Ljava/lang/String;Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:229)
at org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory$RepositoryConfigImpl.getCacheBehaviour(Jcr2spiRepositoryFactory.java:272)
at org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory$RepositoryConfigImpl.<init>(Jcr2spiRepositoryFactory.java:229)
at org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory.getRepository(Jcr2davRepositoryFactory.java:104)
at org.apache.jackrabbit.jcr2dav.Jcr2davRepositoryFactory.getRepository(Jcr2davRepositoryFactory.java:87)
at workarea.core.GetRepositorySize.main(GetRepositorySize.java:25)

To fix the issue add the slf4j-log4j12 with the lower version and also exclude jcl-over-slf4j from jackrabbit-jcr2dav dependency.

<dependency>
 <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.0</version>
</dependency>
 
<!-- https://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-jcr2dav -->
<dependency>
    <groupId>org.apache.jackrabbit</groupId>
    <artifactId>jackrabbit-jcr2dav</artifactId>
    <version>2.17.1</version>
    <scope>provided</scope>
    <exclusions>     
        <exclusion>
         <groupId>org.slf4j</groupId>
         <artifactId>jcl-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.