Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Facing build issues after upgrading AEM SDK API to 2025.8 and JDK21 with test case build time

Avatar

Level 1

Facing below error while trying to upgrader to JDK21 with AEM SDK API 2025.8v, fallowed the steps updated the POM dependencies version to as per the guide, but while building the core with test case i am facing below error for 
Any help would be appreciated. 
java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.xssf.usermodel.XSSFWorkbook
at com.aem.bd.core.workflows.BDTagsReferenceWorkflow.execute(BDTagsReferenceWorkflow.java:28)
at com.aem.bd.core.workflows.BDTagsReferenceWorkflowTest.testBDTagsReferenceWorkflowTest(BDTagsReferenceWorkflowTest.java:87)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.status.StatusLogger$InstanceHolder [in thread "main"]
at org.apache.logging.log4j.status.StatusLogger.getLogger(StatusLogger.java:565)
at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:61)

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

5 Replies

Avatar

Adobe Champion

Based on recent pain, I suggest double-checking on the following:

 

  • Check your pom.xml to make sure correct Apache POI dependencies (org.apache.poi) declared
  • Run mvn dependency:tree to inspect your dependencies tree and identify any issues, especially around transitive dependencies.

 

Rather simple answer for now, but please do get back with your findings and we can take it from there.

Avatar

Level 1

Thank you @KimonP 

I have updated the POI dependency version to 5.2.3 from 4.0.0, and also trying by adding poi-ooxml-schemas, xmlbeans but still with and without these two getting the same error when test casese getting executed on below line of java code. 

try(XSSFWorkbook workbook = new XSSFWorkbook() ){

But when we build by skipping test case, build was fine and validated the functionality working in AEM instance as well.

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
<scope>test</scope>
</dependency>
<!--        <dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>-->

Avatar

Adobe Champion

Thank you for your reply @Srikanth23696837zrx0 .

 

If skipping tests makes the build green, then the break is likely in your test toolchain/code. I’d treat BDTagsReferenceWorkflowTest as the culprit.

 

Try the following (if applicable and/or not done already). I suggest trying one by one and always try if the changed fixed something, avoid bulk-changing:

 

1. Upgrade the test runner & plugins, e.g. 

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<useModulePath>false</useModulePath>
</configuration>
</plugin>

 

2. Move the test to JUnit 5 + Mockito extension, e.g.

@ExtendWith({AemContextExtension.class, MockitoExtension.class})
class BDTagsReferenceWorkflowTest {
    private final AemContext context = new AemContext();
    @Mock WorkflowSession workflowSession;
    @Mock WorkItem workItem;
    @Mock WorkflowData workflowData;
    // ...
}

 

3. Ensure AEM/wcm.io test libs are current, e.g.

<dependency>
  <groupId>io.wcm</groupId>
  <artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
  <version>5.6.10</version>
  <scope>test</scope>
</dependency>

 

4. Avoid using Powermock

Powermock is problematic with later Java versions (see related article)

 

5. If the test still fails: isolate just this test class

mvn -Dtest=BDTagsReferenceWorkflowTest -X test

 

Let me know if any of the above helped!

Avatar

Level 1

Hi @KimonP 

Earlier tried the with both surefire 3.2.5 version and io.wcm.testing.aem-mock.junit5 5.6.10, which created more compile issues like below error with junit5 update from 4.1.0 to 5.6.10 so reverted to old version.
Cannot resolve method 'addModelsForClasses' in 'OsgiContextImpl'

Thanks;

 

 

Avatar

Adobe Champion

That error likely means your test is calling addModelsForClasses(...) on the wrong context type.

 

In JUnit 5 with AEM Mocks 5.x, addModelsForClasses() lives on the Sling/AEM context. If your variable is typed as OsgiContext/OsgiContextImpl, the method doesn’t exist—hence the error.(also see related docs)

 

Try using AEMContext,e.g.

private final AemContext context = new AemContext();

and using it as below examples

context.addModelsForClasses(YourModel.class);

 or

context.addModelsForPackage("com.your.site.models");