Could not initialize class org.apache.sling.testing.mock.osgi.MockEventAdmin

Avatar

Avatar
Validate 1
Level 1
ruchim71073425
Level 1

Likes

2 likes

Total Posts

13 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Boost 1
View profile

Avatar
Validate 1
Level 1
ruchim71073425
Level 1

Likes

2 likes

Total Posts

13 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Boost 1
View profile
ruchim71073425
Level 1

06-04-2021

Hello,

 

We are on AEM 6.4.8 and starting to setup unit test cases.

I have followed the article: 

https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-wknd-tutorial-devel...

 

I have added all dependencies as mentioned in the article, but when trying to run the test, getting the following error:

 

java.lang.NoClassDefFoundError: Could not initialize class org.apache.sling.testing.mock.osgi.MockEventAdmin

at org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerDefaultServices(OsgiContextImpl.java:68)
at org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.setUp(OsgiContextImpl.java:49)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:117)
at io.wcm.testing.mock.aem.context.AemContextImpl.setUp(AemContextImpl.java:96)
at io.wcm.testing.mock.aem.junit5.AemContext.setUpContext(AemContext.java:100)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.setAemContextInStore(AemContextExtension.java:73)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.postProcessTestInstance(AemContextExtension.java:63)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$5(ClassBasedTestDescriptor.java:341)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:346)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassBasedTestDescriptor.java:341)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)

 

Any help will be appreciated.

 

Thanks

Ruchi

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

06-04-2021

Hi @ruchim71073425 

Can you please add the following maven dependency and retry?

<!-- https://mvnrepository.com/artifact/org.apache.sling/org.apache.sling.testing.osgi-mock.junit5 -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.osgi-mock.junit5</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>

Thanks! 

Answers (0)