Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests with JCR_OAK ResourceResolverType fails when upgrading from 2024.9.17964.20240924T170544Z-240800.0000 to 2024.10.18175.20241010T124406Z-240900.0000 #83

Open
koenkicken opened this issue Dec 12, 2024 · 3 comments

Comments

@koenkicken
Copy link

When upgrading wcm.io.aem.sdk.dependencies version 2024.9.17964.20240924T170544Z-240800.0000 to a newer one, and we are using ResourceResolverType.JCR_OAK in io.wcm.testing.mock.aem.junit5.AemContextBuilder we receiving following error:

The JUnit tests using JCR_OAK resource resolver does no longer work when upgrading

java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository
	at io.wcm.testing.mock.aem.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:84)
	at io.wcm.testing.mock.aem.context.AemContextImpl.newResourceResolverFactory(AemContextImpl.java:104)
	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolverFactory(SlingContextImpl.java:208)
	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:192)
	at io.wcm.testing.mock.aem.context.AemContextImpl.setUp(AemContextImpl.java:109)
	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 java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	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.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	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.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: java.lang.RuntimeException: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:391)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.lambda$invokeLifecycleMethod$0(OsgiServiceUtil.java:200)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.findAndInvokeNearestMethod(OsgiServiceUtil.java:153)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeLifecycleMethod(OsgiServiceUtil.java:189)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate(OsgiServiceUtil.java:100)
	at org.apache.sling.testing.mock.osgi.MockOsgi.registerInjectActivateService(MockOsgi.java:254)
	at org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.registerServiceIfNotPresent(ResourceResolverFactoryInitializer.java:227)
	at org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.registerServiceIfNotPresent(ResourceResolverFactoryInitializer.java:210)
	at org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.setUp(ResourceResolverFactoryInitializer.java:73)
	at org.apache.sling.testing.mock.sling.MockSling.buildFactoryFromRepository(MockSling.java:115)
	at org.apache.sling.testing.mock.sling.MockSling.newResourceResolverFactory(MockSling.java:97)
	at io.wcm.testing.mock.aem.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:56)
	... 21 more
@koenkicken koenkicken changed the title tests with OAK fails when upgrading from 2024.9.17964.20240924T170544Z-240800.0000 to 2024.10.18175.20241010T124406Z-240900.0000 tests with JCR_OAK ResourceResolverType fails when upgrading from 2024.9.17964.20240924T170544Z-240800.0000 to 2024.10.18175.20241010T124406Z-240900.0000 Dec 12, 2024
@stefanseifert
Copy link
Member

i cannot reproduce this issue e.g. by setting to that AEMaaCS version on this testing branch: https://github.com/wcm-io/io.wcm.testing.aem-mock/tree/testing/aemcloud-deps

also it looks as the stack trace is cut off - there should be more info why the "activate" method actually has failed?

please also check if you are using the latest versions of sling-org-apache-sling-testing-sling-mock-oak and of AEM Mocks.

@koenkicken
Copy link
Author

@stefanseifert we are running on the latest versions

           <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
                <version>4.0.0-1.62.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>io.wcm</groupId>
                <artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
                <version>5.6.4</version>
                <scope>test</scope>
            </dependency>

This is the full trace I am getting:

java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository

	at io.wcm.testing.mock.aem.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:84)
	at io.wcm.testing.mock.aem.context.AemContextImpl.newResourceResolverFactory(AemContextImpl.java:104)
	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolverFactory(SlingContextImpl.java:208)
	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:192)
	at io.wcm.testing.mock.aem.context.AemContextImpl.setUp(AemContextImpl.java:109)
	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 java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	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.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	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.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: java.lang.RuntimeException: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:391)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.lambda$invokeLifecycleMethod$0(OsgiServiceUtil.java:200)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.findAndInvokeNearestMethod(OsgiServiceUtil.java:153)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeLifecycleMethod(OsgiServiceUtil.java:189)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate(OsgiServiceUtil.java:100)
	at org.apache.sling.testing.mock.osgi.MockOsgi.registerInjectActivateService(MockOsgi.java:254)
	at org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.registerServiceIfNotPresent(ResourceResolverFactoryInitializer.java:227)
	at org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.registerServiceIfNotPresent(ResourceResolverFactoryInitializer.java:210)
	at org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.setUp(ResourceResolverFactoryInitializer.java:73)
	at org.apache.sling.testing.mock.sling.MockSling.buildFactoryFromRepository(MockSling.java:115)
	at org.apache.sling.testing.mock.sling.MockSling.newResourceResolverFactory(MockSling.java:97)
	at io.wcm.testing.mock.aem.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:56)
	... 21 more
Caused by: java.lang.NoClassDefFoundError: org/apache/jackrabbit/oak/commons/collections/CollectionUtils
	at org.apache.jackrabbit.oak.plugins.name.Namespaces.buildIndexNode(Namespaces.java:141)
	at org.apache.jackrabbit.oak.plugins.name.Namespaces.setupNamespaces(Namespaces.java:87)
	at org.apache.jackrabbit.oak.InitialContent.initialize(InitialContent.java:86)
	at org.apache.jackrabbit.oak.spi.lifecycle.CompositeInitializer.initialize(CompositeInitializer.java:47)
	at org.apache.jackrabbit.oak.OakInitializer.initialize(OakInitializer.java:47)
	at org.apache.jackrabbit.oak.Oak.initialContent(Oak.java:702)
	at org.apache.jackrabbit.oak.Oak.createNewContentRepository(Oak.java:744)
	at org.apache.jackrabbit.oak.Oak.createContentRepository(Oak.java:686)
	at org.apache.jackrabbit.oak.jcr.Jcr.createContentRepository(Jcr.java:389)
	at org.apache.jackrabbit.oak.jcr.Jcr.createRepository(Jcr.java:398)
	at org.apache.sling.testing.mock.sling.oak.OakMockSlingRepository.activate(OakMockSlingRepository.java:98)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:376)
	... 32 more
Caused by: java.lang.ClassNotFoundException: org.apache.jackrabbit.oak.commons.collections.CollectionUtils
	at 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:527)
	... 45 more

@stefanseifert
Copy link
Member

it looks like a classpath problem in your project.
please make a mvn dependency:tree and check for all references with "oak" in it's name. all oak dependencies should have version 1.62.0.
afaik the class org.apache.jackrabbit.oak.commons.collections.CollectionUtils that is not found here was added in a later version of oak, so it seems some version mixup is happening in your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants