[JIRA] (WTES-67) Upgrading io.wcm.handler.media to latest version causing test cases failure

83 views
Skip to first unread message

Himanshu Singhal (JIRA)

unread,
Aug 25, 2021, 1:56:00 AM8/25/21
to wcm-i...@googlegroups.com
Himanshu Singhal created WTES-67:
------------------------------------

Summary: Upgrading io.wcm.handler.media to latest version causing test cases failure
Key: WTES-67
URL: https://wcm-io.atlassian.net/browse/WTES-67
Project: wcm.io Testing
Issue Type: Bug
Components: wcm.io Mocks
Reporter: Himanshu Singhal
Priority: Critical


I've upgraded all the wcm.io dependencies and especially after upgrading
{code:java}
io.wcm.handler.media
{code}

started to get following error in almost all test cases.


{code:java}
java.lang.RuntimeException: After setup failed (io.wcm.testing.mock.wcmio.handler.ContextPlugins$1@574cd322): Unable to inject mandatory reference 'featureFlagService' for class io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportServiceImpl : no matching services were found.

at org.apache.sling.testing.mock.osgi.context.ContextPlugins.executeAfterSetUpCallback(ContextPlugins.java:218)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.lambda$beforeEach$1(AemContextExtension.java:129)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.applyAemContext(AemContextExtension.java:180)
at io.wcm.testing.mock.aem.junit5.AemContextExtension.beforeEach(AemContextExtension.java:127)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:159)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:195)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:195)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:158)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:125)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.apache.sling.testing.mock.osgi.ReferenceViolationException: Unable to inject mandatory reference 'featureFlagService' for class io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportServiceImpl : no matching services were found.
at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.injectServiceReference(OsgiServiceUtil.java:623)
at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.injectServices(OsgiServiceUtil.java:439)
at org.apache.sling.testing.mock.osgi.MockOsgi.injectServices(MockOsgi.java:161)
at org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:153)
at org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:168)
at io.wcm.testing.mock.wcmio.handler.ContextPlugins.registerOptional(ContextPlugins.java:99)
at io.wcm.testing.mock.wcmio.handler.ContextPlugins.setUp(ContextPlugins.java:78)
at io.wcm.testing.mock.wcmio.handler.ContextPlugins$1.afterSetUp(ContextPlugins.java:49)
at io.wcm.testing.mock.wcmio.handler.ContextPlugins$1.afterSetUp(ContextPlugins.java:46)
at org.apache.sling.testing.mock.osgi.context.ContextPlugins.executeAfterSetUpCallback(ContextPlugins.java:215)
... 52 more


{code}




--
This message was sent by Atlassian Jira
(v1001.0.0-SNAPSHOT#100174)

Himanshu Singhal (JIRA)

unread,
Aug 25, 2021, 1:56:32 AM8/25/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Himanshu Singhal updated WTES-67:
---------------------------------
Description:
I've upgraded all the wcm.io dependencies and especially after upgrading

{code:java}io.wcm.handler.media to version 1.13.0{code}
was:
> Upgrading io.wcm.handler.media to latest version causing test cases failure
> ---------------------------------------------------------------------------
>
> Key: WTES-67
> URL: https://wcm-io.atlassian.net/browse/WTES-67
> Project: wcm.io Testing
> Issue Type: Bug
> Components: wcm.io Mocks
> Reporter: Himanshu Singhal
> Priority: Critical
>
> I've upgraded all the wcm.io dependencies and especially after upgrading
> {code:java}io.wcm.handler.media to version 1.13.0{code}

Stefan Seifert (JIRA)

unread,
Aug 25, 2021, 3:14:41 AM8/25/21
to wcm-i...@googlegroups.com

Himanshu Singhal (JIRA)

unread,
Aug 25, 2021, 3:21:09 AM8/25/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21340#comment-21340 ]

Himanshu Singhal commented on WTES-67:
--------------------------------------

Yes, I did to latest version.


{noformat}<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.handler</artifactId>
<version>1.4.0</version>
</dependency>{noformat}

Stefan Seifert (JIRA)

unread,
Aug 25, 2021, 12:29:13 PM8/25/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21343#comment-21343 ]

Stefan Seifert commented on WTES-67:
------------------------------------

coming back to your actual stack trace - support for the "feature flag service" from sling was added with SLING-10019 a while ago (since sling-mock 2.7.0) - please make sure you are using the latest aem-mock version *and* you are not specifying additionally a sling-mock version. the fitting sling-mock version comes as references in aem-mock.

it looks you have an outdated sling-mock dependency in your project.

Himanshu Singhal (JIRA)

unread,
Aug 26, 2021, 4:15:34 AM8/26/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21345#comment-21345 ]

Himanshu Singhal commented on WTES-67:
--------------------------------------

Using the latest AEM-Mock


{noformat} <dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>4.1.0</version>
</dependency>{noformat}

Had sling-mock version as well but now I’ve removed it and it solves the major problem. However, for few test case which using {{ ResourceResolverType.JCR_OAK }} - test cases fails because of the removal of sling-mock dependency.



{noformat}java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: Unable to instantiate resourcer resolver: org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter. Make sure this maven dependency is included: org.apache.sling:org.apache.sling.testing.sling-mock-oak
at io.wcm.testing.mock.aem.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:72)
at io.wcm.testing.mock.aem.context.AemContextImpl.newResourceResolverFactory(AemContextImpl.java:99)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolverFactory(SlingContextImpl.java:150)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:134)
at io.wcm.testing.mock.aem.context.AemContextImpl.setUp(AemContextImpl.java:104)
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$6(ClassBasedTestDescriptor.java:350)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:355)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$7(ClassBasedTestDescriptor.java:350)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:349)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$4(ClassBasedTestDescriptor.java:270)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:269)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:259)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:258)
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:101)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:100)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:65)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79)
Caused by: java.lang.RuntimeException: Unable to instantiate resourcer resolver: org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter. Make sure this maven dependency is included: org.apache.sling:org.apache.sling.testing.sling-mock-oakat org.apache.sling.testing.mock.sling.MockSling.getResourceResolverTypeAdapter(MockSling.java:93)at org.apache.sling.testing.mock.sling.MockSling.newResourceResolverFactory(MockSling.java:72)at io.wcm.testing.mock.aem.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:50)... 79 moreCaused by: java.lang.ClassNotFoundException: org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapterat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)at java.base/java.lang.Class.forName0(Native Method)at java.base/java.lang.Class.forName(Class.java:315)at org.apache.sling.testing.mock.sling.MockSling.getResourceResolverTypeAdapter(MockSling.java:86)... 81 more{noformat}
(v1001.0.0-SNAPSHOT#100175)

Stefan Seifert (JIRA)

unread,
Aug 26, 2021, 4:28:05 AM8/26/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21346#comment-21346 ]

Stefan Seifert commented on WTES-67:
------------------------------------

you have to keep the sling-mock-oak dependency (it's an optional dependency not included by default with aem-mock) - but remove potential other sling-mock dependencies.

Himanshu Singhal (JIRA)

unread,
Aug 26, 2021, 8:54:48 AM8/26/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21348#comment-21348 ]

Himanshu Singhal commented on WTES-67:
--------------------------------------

I think I’m still missing something as if I remove the sling-mock-oak then only a few test case fail which using {{ ResourceResolverType.JCR_OAK }} .
However, if I keep it then almost all test case failing due to error {{ java.lang.RuntimeException: After setup failed (io.wcm.testing.mock.wcmio.handler.ContextPlugins$1@574cd322): Unable }} *to* {{ inject mandatory reference 'featureFlagService' }} *for* {{ }} *class* {{ io.wcm.handler.mediasource.dam.impl.dynamicmedia.DynamicMediaSupportServiceImpl : no matching services were found. }}

Here’s the dependencies with latest version that are part of core bundle:



{noformat} <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.logging-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.caconfig</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.sling</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.wcm</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.handler</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>{noformat}

Stefan Seifert (JIRA)

unread,
Aug 26, 2021, 9:04:09 AM8/26/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21349#comment-21349 ]

Stefan Seifert commented on WTES-67:
------------------------------------

maybe you are using a very old/outdated version of sling-mock-oak (e.g. < 2.1.0) - this may let creep in an old version of sling-mock before the split for junit4/junit5.
besides this, the dependency declarations look fine (but without actual versions it's difficult to tell)

Himanshu Singhal (JIRA)

unread,
Aug 26, 2021, 9:22:57 AM8/26/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21350#comment-21350 ]

Himanshu Singhal commented on WTES-67:
--------------------------------------

Here’s the dependencies with versions



{noformat} <!-- wcm.io Testing -->
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.logging-mock</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Tests with sling-mock-oak doesn't work with Java version > 9 without this version.-->
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-api</artifactId>
<version>2.19.3</version>
</dependency>
<!-- <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
<version>2.1.10-1.16.0</version>
</dependency> -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.caconfig</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.sling</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.wcm</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.wcm-io-mock.handler</artifactId>
<version>1.4.0</version>
</dependency>{noformat}

Stefan Seifert (JIRA)

unread,
Aug 29, 2021, 6:21:08 AM8/29/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21351#comment-21351 ]

Stefan Seifert commented on WTES-67:
------------------------------------

i was able to reproduce the problem.

a quick fix to get is running is to add this to the dependency for {{ org.apache.sling.testing.sling-mock-oak }} :

{code:xml}
<exclusions>
<exclusion>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock.core</artifactId>
</exclusion>
</exclusions>
{code}

further i recommend to remove the dependency to org.apache.jackrabbit:jackrabbit-api, should not be required (at least it still worked when removing it in my test). but it should not be an issue for the problem described in this ticket.

to avoid problems like this in the future i've created https://issues.apache.org/jira/browse/SLING-10762 - with the next version the exclusion should not longer be required.

Himanshu Singhal (JIRA)

unread,
Aug 29, 2021, 8:47:47 AM8/29/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21352#comment-21352 ]

Himanshu Singhal commented on WTES-67:
--------------------------------------

Thank you\! It works\!\!
May I point another bug? Not sure if it’s relevant here…

If I include
{{ import com.adobe.cq.wcm.core.components.models.Tabs; }}
{{ @Self @Via(type = ResourceSuperType.class) @NotNull Tabs coreTabs, }}

in custom model and write test case for it, it throws following error:


{noformat} Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject FakeAnnotatedElement [annotations=[@org.apache.sling.models.annotations.injectorspecific.Self(optional=false, injectionStrategy=DEFAULT), @org.apache.sling.models.annotations.Via(type=org.apache.sling.models.annotations.via.ResourceSuperType.class, value="")], parameterIndex=0]
at org.apache.sling.models.impl.ModelAdapterFactory.newInstanceWithConstructorInjection(ModelAdapterFactory.java:816)
... 75 more
Caused by: org.apache.sling.models.factory.ModelClassException: Could not create model from class org.apache.sling.models.impl.via.AbstractResourceTypeViaProvider$ResourceTypeForcingRequestWrapper: Could not inject all required fields into class com.adobe.cq.wcm.core.components.internal.models.v1.TabsImpl
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1057)
at org.apache.sling.models.impl.ModelAdapterFactory.adaptIfNecessary(ModelAdapterFactory.java:1032)
at org.apache.sling.models.impl.ModelAdapterFactory.setConstructorParameter(ModelAdapterFactory.java:996)
at org.apache.sling.models.impl.ModelAdapterFactory.access$400(ModelAdapterFactory.java:115)
at org.apache.sling.models.impl.ModelAdapterFactory$SetConstructorParameterCallback.inject(ModelAdapterFactory.java:501)
at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:573)
at org.apache.sling.models.impl.ModelAdapterFactory.newInstanceWithConstructorInjection(ModelAdapterFactory.java:811)
... 75 more
Caused by: org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.adobe.cq.wcm.core.components.internal.models.v1.TabsImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:752)
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:421)
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1051)
... 81 more
Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject protected com.adobe.cq.wcm.core.components.internal.link.LinkHandler com.adobe.cq.wcm.core.components.internal.models.v1.AbstractContainerImpl.linkHandler
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:736)
... 83 more
Caused by: org.apache.sling.models.factory.ModelClassException: Could not adapt from class org.apache.sling.models.impl.via.AbstractResourceTypeViaProvider$ResourceTypeForcingRequestWrapper to class com.adobe.cq.wcm.core.components.internal.link.LinkHandler
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1062)
at org.apache.sling.models.impl.ModelAdapterFactory.adaptIfNecessary(ModelAdapterFactory.java:1032)
at org.apache.sling.models.impl.ModelAdapterFactory.setField(ModelAdapterFactory.java:975)
at org.apache.sling.models.impl.ModelAdapterFactory.access$200(ModelAdapterFactory.java:115)
at org.apache.sling.models.impl.ModelAdapterFactory$SetFieldCallback.inject(ModelAdapterFactory.java:473)
at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:573)
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:731)
... 83 more{noformat}


Upon checking further details, following dependency is part of code base without version


{noformat} <dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.core</artifactId>
<scope>compile</scope>
</dependency>{noformat}

it takes the latest version i.e. 2.17.8. However, it has one the component model {{ com.adobe.cq.wcm.core.components.models.Tabs }} which internally extends one of the class {{ AbstractComponentImpl }} that has injected model

{noformat} @Self
protected LinkHandler linkHandler;{noformat}

This model again injecting one the service


{noformat} @OSGiService
private List<PathProcessor> pathProcessors;{noformat}

which is causing the issue. If I degrade the dependency to lower version then it doesn’t have {{ LinkHandler }} class and test case succeed.

Stefan Seifert (JIRA)

unread,
Aug 29, 2021, 10:57:40 AM8/29/21
to wcm-i...@googlegroups.com

Himanshu Singhal (JIRA)

unread,
Sep 8, 2021, 3:22:53 AM9/8/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21359#comment-21359 ]

Himanshu Singhal commented on WTES-67:
--------------------------------------

Works fine now with latest core component test dependency. Thank you\!

Stefan Seifert (JIRA)

unread,
Sep 8, 2021, 3:33:09 AM9/8/21
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-67?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Seifert closed WTES-67.
------------------------------
Resolution: Fixed
Reply all
Reply to author
Forward
0 new messages