[mocks] weird RT exception with JCR_MOCK

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[mocks] weird RT exception with JCR_MOCK

Nicolas Peltier-3
Hi,

When adding o.a.s.jcr.resource to sling pipes (for JcrResourceConstants), mocks fail to run with exception [0]. I started playing around with exclusions and dependency without success and figured out I could ask here if anybody had this issue before.

Any clue?
Nicolas

[0] Caused by: java.lang.NoClassDefFoundError: org/apache/jackrabbit/oak/jcr/observation/filter/OakEventFilter
        at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.registerListeners(JcrResourceProvider.java:197)
        at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.start(JcrResourceProvider.java:161)
        at org.apache.sling.resourceresolver.impl.providers.ResourceProviderHandler.activate(ResourceProviderHandler.java:53)
        at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.activate(ResourceProviderTracker.java:282)
        at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.register(ResourceProviderTracker.java:173)
        at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.access$200(ResourceProviderTracker.java:58)
        at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1.addingService(ResourceProviderTracker.java:123)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
        at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
        at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
        at org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.activate(ResourceProviderTracker.java:127)
        at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.activate(ResourceResolverFactoryActivator.java:485)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:311)
        ... 33 more
Reply | Threaded
Open this post in threaded view
|

Re: [mocks] weird RT exception with JCR_MOCK

Stefan Egli-2
Hi Nicolas,

OakEventFilter got added to oak in 1.6, so it looks like you have a
dependency on oak 1.6 but are running on an older version.


Cheers,
Stefan

On 06/07/17 10:20, "Nicolas Peltier" <[hidden email]> wrote:

>Hi,
>
>When adding o.a.s.jcr.resource to sling pipes (for JcrResourceConstants),
>mocks fail to run with exception [0]. I started playing around with
>exclusions and dependency without success and figured out I could ask
>here if anybody had this issue before.
>
>Any clue?
>Nicolas
>
>[0] Caused by: java.lang.NoClassDefFoundError:
>org/apache/jackrabbit/oak/jcr/observation/filter/OakEventFilter
> at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.regi
>sterListeners(JcrResourceProvider.java:197)
> at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.star
>t(JcrResourceProvider.java:161)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderHandler.a
>ctivate(ResourceProviderHandler.java:53)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.a
>ctivate(ResourceProviderTracker.java:282)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.r
>egister(ResourceProviderTracker.java:173)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.a
>ccess$200(ResourceProviderTracker.java:58)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1
>.addingService(ResourceProviderTracker.java:123)
> at
>org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTrack
>er.java:941)
> at
>org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTrack
>er.java:870)
> at
>org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256
>)
> at
>org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:18
>3)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.a
>ctivate(ResourceProviderTracker.java:127)
> at
>org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.ac
>tivate(ResourceResolverFactoryActivator.java:485)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>62)
> at
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm
>pl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
>org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServic
>eUtil.java:311)
> ... 33 more


Reply | Threaded
Open this post in threaded view
|

RE: [mocks] weird RT exception with JCR_MOCK

Stefan Seifert
In reply to this post by Nicolas Peltier-3
the latest versions of org.apache.sling.jcr.resource come with a direct dependency to oak, which is declared as "provided", so it's not automatically present in your unit tests.

sling-mock itself references an older jcr.resource withouth this dependency, so this normally works. i assume you reference a newer version of jcr.resource in your project, so you have to add a dependency to org.apache.jackrabbit.oak-jcr as well.

stefan

>-----Original Message-----
>From: Nicolas Peltier [mailto:[hidden email]]
>Sent: Thursday, July 6, 2017 10:21 AM
>To: [hidden email]
>Subject: [mocks] weird RT exception with JCR_MOCK
>
>Hi,
>
>When adding o.a.s.jcr.resource to sling pipes (for JcrResourceConstants),
>mocks fail to run with exception [0]. I started playing around with
>exclusions and dependency without success and figured out I could ask here
>if anybody had this issue before.
>
>Any clue?
>Nicolas
>
>[0] Caused by: java.lang.NoClassDefFoundError:
>org/apache/jackrabbit/oak/jcr/observation/filter/OakEventFilter
> at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.regis
>terListeners(JcrResourceProvider.java:197)
> at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.start
>(JcrResourceProvider.java:161)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderHandler.ac
>tivate(ResourceProviderHandler.java:53)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.ac
>tivate(ResourceProviderTracker.java:282)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.re
>gister(ResourceProviderTracker.java:173)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.ac
>cess$200(ResourceProviderTracker.java:58)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1.
>addingService(ResourceProviderTracker.java:123)
> at
>org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracke
>r.java:941)
> at
>org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracke
>r.java:870)
> at
>org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
> at
>org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183
>)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
> at
>org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.ac
>tivate(ResourceProviderTracker.java:127)
> at
>org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.act
>ivate(ResourceResolverFactoryActivator.java:485)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:6
>2)
> at
>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
>l.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
>org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiService
>Util.java:311)
> ... 33 more

Reply | Threaded
Open this post in threaded view
|

Re: [mocks] weird RT exception with JCR_MOCK

Nicolas Peltier-3
Thanks Stefan for the analysis!

Did use same jcr.resource version as sling mocks’ and it did the trick (I only this dep for constants), hope it’s not (too much of a) bad practice

Nicolas

> On 6 Jul 2017, at 10:48, Stefan Seifert <[hidden email]> wrote:
>
> the latest versions of org.apache.sling.jcr.resource come with a direct dependency to oak, which is declared as "provided", so it's not automatically present in your unit tests.
>
> sling-mock itself references an older jcr.resource withouth this dependency, so this normally works. i assume you reference a newer version of jcr.resource in your project, so you have to add a dependency to org.apache.jackrabbit.oak-jcr as well.
>
> stefan
>
>> -----Original Message-----
>> From: Nicolas Peltier [mailto:[hidden email]]
>> Sent: Thursday, July 6, 2017 10:21 AM
>> To: [hidden email]
>> Subject: [mocks] weird RT exception with JCR_MOCK
>>
>> Hi,
>>
>> When adding o.a.s.jcr.resource to sling pipes (for JcrResourceConstants),
>> mocks fail to run with exception [0]. I started playing around with
>> exclusions and dependency without success and figured out I could ask here
>> if anybody had this issue before.
>>
>> Any clue?
>> Nicolas
>>
>> [0] Caused by: java.lang.NoClassDefFoundError:
>> org/apache/jackrabbit/oak/jcr/observation/filter/OakEventFilter
>> at
>> org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.regis
>> terListeners(JcrResourceProvider.java:197)
>> at
>> org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.start
>> (JcrResourceProvider.java:161)
>> at
>> org.apache.sling.resourceresolver.impl.providers.ResourceProviderHandler.ac
>> tivate(ResourceProviderHandler.java:53)
>> at
>> org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.ac
>> tivate(ResourceProviderTracker.java:282)
>> at
>> org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.re
>> gister(ResourceProviderTracker.java:173)
>> at
>> org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.ac
>> cess$200(ResourceProviderTracker.java:58)
>> at
>> org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1.
>> addingService(ResourceProviderTracker.java:123)
>> at
>> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracke
>> r.java:941)
>> at
>> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracke
>> r.java:870)
>> at
>> org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
>> at
>> org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183
>> )
>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:318)
>> at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)
>> at
>> org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.ac
>> tivate(ResourceProviderTracker.java:127)
>> at
>> org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.act
>> ivate(ResourceResolverFactoryActivator.java:485)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:6
>> 2)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
>> l.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:498)
>> at
>> org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiService
>> Util.java:311)
>> ... 33 more
>