Skip to main content
vijaym76986902
New Participant
July 2, 2018
Question

AEM 6.3 JUnit dependency issue

  • July 2, 2018
  • 1 reply
  • 1201 views

I have added all the pom dependency with Junit, WCM io, Sling Jcr dependency.But still when i am running junit the below error is throwing when resource is adopting to page or node.

java.lang.NoSuchMethodError: org.osgi.framework.BundleContext.getServiceReference(Ljava/lang/Class;)Lorg/osgi/framework/ServiceReference;

    at org.apache.sling.testing.mock.sling.ThreadsafeMockAdapterManagerWrapper$AdapterManagerBundleContextFactory.getAdapterManager(ThreadsafeMockAdapterManagerWrapper.java:90)

    at org.apache.sling.testing.mock.sling.ThreadsafeMockAdapterManagerWrapper.getAdapter(ThreadsafeMockAdapterManagerWrapper.java:45)

    at org.apache.sling.api.adapter.SlingAdaptable.adaptTo(SlingAdaptable.java:104).

What could the reason for this exception.

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

1 reply

sateaswa94
New Participant
January 17, 2023

AEM context will work only for the version 6.0.0 and above for osgi core and osgi cmpn. Update your pom dependency to fix the issue

<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>osgi.core</artifactId>
    <version>6.0.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>osgi.cmpn</artifactId>
    <version>6.0.0</version>
    <scope>provided</scope>
</dependency>