Unable to initialize JCR_MOCK resource resolver factory in Cloud Pipeline | Community
Skip to main content
Level 2
June 5, 2023

Unable to initialize JCR_MOCK resource resolver factory in Cloud Pipeline

  • June 5, 2023
  • 3 replies
  • 2902 views

Hi Guys,

 

I am getting below error while doing cloud migration, in my unit test cases

 

20:07:17,294 [ThreadedStreamConsumer] [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.394 s <<< FAILURE! - in com.abcd.core.services.LocaliseLinksActionFactoryTest
20:07:17,341 [ThreadedStreamConsumer] [ERROR] com.abcd.core.services.LocaliseLinksActionFactoryTest Time elapsed: 1.392 s <<< ERROR!
java.lang.RuntimeException: Unable to initialize JCR_MOCK resource resolver factory: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.MockJcrSlingRepository
Caused by: java.lang.RuntimeException: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.MockJcrSlingRepository
Caused by: java.lang.UnsupportedClassVersionError: org/apache/jackrabbit/api/observation/JackrabbitObservationManager has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

 

 below is my maven compiler plugin dependency and other important dependencies. 

 

 

<!-- Maven Compiler Plugin -->
<plugin>

<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
 
<aem-sdk-api.version>2023.3.11382.20230315T073850Z-230200</aem-sdk-api.version>
<jackrabbit-core.version>2.21.15</jackrabbit-core.version>
<org.apache.sling.testing.osgi-mock.junit5.version>3.0.0</org.apache.sling.testing.osgi-mock.junit5.version>
<org.apache.sling.testing.sling-mock.version>3.4.10</org.apache.sling.testing.sling-mock.version>
 
What am i missing?  any points will be really appreciated.
 
Thanks,
Abhishek
 
 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

joerghoh
Adobe Employee
Adobe Employee
June 8, 2023

Unfortunately you don't mention if you get this exception locally or as part of a AEM CS pipeline. In case of a local build, switch to Java 11.

Level 2
July 7, 2023

yes that was in CS pipeline. we have upgraded the dependencies and it resolved the issue. Most were pom fixes. 

Level 2
June 12, 2023

Hello we have the same problem from 2023.3.11382+ , have you fixed it ? 

Level 2
June 13, 2023

Hello we've fixed the issue forcing to use Java 11 on Cloud 

Level 2
July 7, 2023

Hi , we upgraded the dependencies and fixed the pom with correct entries in main and /core poms that fixed it.

October 3, 2023

we are also facing same issue is AEM CS pipeline. 

 

we have below dependencies in parent POM . please advice what changes I should be making to make  JCR_MOCK work.
<dependency>                
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.8.2</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>4.1.0</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-junit-jupiter</artifactId>
        <version>4.1.0</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>junit-addons</groupId>
        <artifactId>junit-addons</artifactId>
        <version>1.4</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>io.wcm</groupId>
        <artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
        <version>5.1.2</version>
        <scope>test</scope>
        <exclusions>
          <exclusion>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.api</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
        <version>1.4.0</version>
        <exclusions>
          <exclusion>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
      <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>com.adobe.cq</groupId>              
        <artifactId>core.wcm.components.testing.aem-mock-plugin</artifactId>              
        <version>${core.wcm.components.version}</version>                
        <scope>test</scope>                
        <exclusions>                    
          <exclusion>                      
            <groupId>org.apache.sling</groupId>                        
            <artifactId>org.apache.sling.scripting.api</artifactId>                    
          </exclusion>                
        </exclusions>            
      </dependency>          
      <dependency>              
        <groupId>uk.org.lidalia</groupId>              
        <artifactId>slf4j-test</artifactId>                
        <version>1.0.1</version>                
        <scope>test</scope>              
      </dependency>
</dependencies>