RE: sling mocks "Creating resource resolver failed"

2017-04-28 Thread Stefan Seifert

>I tried updating the resourceresolver version to 1.5.22 but got a different
>error:

just hit this as well - also try osgi-mock 2.2.5-SNAPSHOT with the fix from 
SLING-6811

stefan



Re: sling mocks "Creating resource resolver failed"

2017-04-28 Thread Santiago Garcia Pimentel
org.apache.sling.resourceresolver 1.4.8
org.apache.sling.api 2.16.2

I tried updating the resourceresolver version to 1.5.22 but got a different 
error:

java.lang.RuntimeException: Unable to initialize JCR_MOCK resource resolver 
factory: Unable to invoke method 'activate' for class 
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator
at 
org.apache.sling.testing.mock.sling.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:66)
at 
org.apache.sling.testing.mock.sling.context.SlingContextImpl.newResourceResolverFactory(SlingContextImpl.java:130)
at 
org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:121)
at 
org.apache.sling.testing.mock.sling.junit.SlingContext.access$100(SlingContext.java:40)
at 
org.apache.sling.testing.mock.sling.junit.SlingContext$1.before(SlingContext.java:127)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.RuntimeException: Unable to invoke method 'activate' for 
class org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator
at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:320)
at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeLifecycleMethod(OsgiServiceUtil.java:213)
at 
org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate(OsgiServiceUtil.java:84)
at 
org.apache.sling.testing.mock.osgi.MockOsgi.activate(MockOsgi.java:171)
at 
org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.initializeResourceResolverFactoryActivator(ResourceResolverFactoryInitializer.java:129)
at 
org.apache.sling.testing.mock.sling.ResourceResolverFactoryInitializer.setUp(ResourceResolverFactoryInitializer.java:74)
at 
org.apache.sling.testing.mock.sling.MockSling.newResourceResolverFactory(MockSling.java:75)
at 
org.apache.sling.testing.mock.sling.context.ContextResourceResolverFactory.get(ContextResourceResolverFactory.java:45)
... 21 more
Caused by: java.lang.UnsupportedOperationException
at 
org.apache.sling.testing.mock.osgi.MockBundleContext.getBundle(MockBundleContext.java:454)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.checkFactoryPreconditions(ResourceResolverFactoryActivator.java:537)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator.access$100(ResourceResolverFactoryActivator.java:72)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryActivator$1.providerAdded(ResourceResolverFactoryActivator.java:382)
at 
org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.register(ResourceProviderTracker.java:200)
at 
org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker.access$200(ResourceProviderTracker.java:59)
at 
org.apache.sling.resourceresolver.impl.providers.ResourceProviderTracker$1.addingService(ResourceProviderTracker.java:128)
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)
  

RE: sling mocks "Creating resource resolver failed"

2017-04-28 Thread Stefan Seifert
and which version of the following bundles are used?

org.apache.sling.resourceresolver
org.apache.sling.api

stefan


>-Original Message-
>From: Santiago Garcia Pimentel [mailto:santiago.pimen...@netcentric.biz]
>Sent: Friday, April 28, 2017 12:49 PM
>To: users@sling.apache.org
>Subject: Re: sling mocks "Creating resource resolver failed"
>
>Hi Stefan,
>
>Sure. I think most of it is in the newest or a very recent version.
>
>Sling-mock 2.2.6
>ResourceResolver-mock 1.1.16
>sling-mock-oak 2.0.2
>jcr-mock 1.2.0
>org.apache.sling.jcr.resource 2.9.2
>
>The problem, I think is that sling mocks uses the loginAdministrative when
>using JCR_MOCK and that doesn't work anymore since it requires to be
>whitelisted. Im not sure if this is a bug or I have to whitelist it
>somehow.
>
>Greetings.
>
>Santiago García Pimentel| Sr Software Engineer
>Netcentric Ibérica SLU
>M: +34687915463
>santiago.pimen...@netcentric.biz 
>| www.netcentric.biz 
>> On Apr 28, 2017, at 12:35 PM, Stefan Seifert 
>wrote:
>>
>> can you provide more details with version of sling mock you are using?
>> and if you are overrding some of it's dependencies (e.g.
>org.apache.sling.resourceresolver or org.apache.sling.jcr.resource) with
>other versions?
>>
>> you might also try to move sling-mock test dependency to the top in your
>project POM to avoid conflicting transitive dependency.
>>
>> stefan
>>
>>> -Original Message-
>>> From: Santiago Garcia Pimentel [mailto:santiago.pimen...@netcentric.biz]
>>> Sent: Friday, April 28, 2017 12:33 PM
>>> To: users@sling.apache.org
>>> Subject: sling mocks "Creating resource resolver failed"
>>>
>>> Hello,
>>>
>>> Im trying to use sling mocks and Im having problems when creating
>content
>>> when using the JCR_MOCK.
>>>
>>> When trying to create a resource with :
>>>
>>>   @Rule
>>>   public final SlingContext context = new
>>> SlingContext(ResourceResolverType.JCR_MOCK);
>>>
>>> and
>>>
>>> context.create().resource("/content/web", ImmutableMap.of("jcr:title",
>>> "web"));
>>>
>>> I get java.lang.RuntimeException: Creating resource resolver failed.
>>> at
>>>
>org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolv
>>> er(SlingContextImpl.java:250)
>>> at
>>>
>org.apache.sling.testing.mock.sling.context.SlingContextImpl.create(SlingCo
>>> ntextImpl.java:335)
>>>
>>> …..
>>> Caused by: org.apache.sling.api.resource.LoginException: Calling bundle
>>> missing in authentication info
>>> at
>>>
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrProviderStateFactory.c
>>> reateProviderState(JcrProviderStateFactory.java:129)
>>> at
>>>
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.authe
>>> nticate(JcrResourceProvider.java:284)
>>> at
>>>
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.authe
>>> nticate(JcrResourceProvider.java:75)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.a
>>> uthenticate(ProviderManager.java:161)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.g
>>> etOrCreateProvider(ProviderManager.java:87)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.a
>>> uthenticateAll(ProviderManager.java:129)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.ResourceResolverImpl.createControl(R
>>> esourceResolverImpl.java:154)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.ResourceResolverImpl.(Resource
>>> ResolverImpl.java:116)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.ResourceResolverImpl.(Resource
>>> ResolverImpl.java:110)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.ge
>>> tResourceResolverInternal(CommonResourceResolverFactoryImpl.java:257)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.ge
>>>
>tAdministrativeResourceResolver(CommonResourceResolverFactoryImpl.java:140)
>>> at
>>>
>org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getAdmin
>>> istrativeResourceResolver(ResourceResolverFactoryImpl.java:107)
>>> at
>>>
>org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolv
>>> er(SlingContextImpl.java:248)
>>> ... 27 more
>>>
>>>
>>>
>>> It seems to be caused by the recent changes in the use of administrative
>>> resource resolver, and Im not sure how to make it work. Anyone has a tip
>on
>>> this?
>>>
>>> Santiago García Pimentel| Sr Software Engineer
>>> Netcentric Ibérica SLU
>>> M: +34687915463
>>> santiago.pimen...@netcentric.biz  | www.netcentric.biz
>>



RE: sling mocks "Creating resource resolver failed"

2017-04-28 Thread Stefan Seifert
can you provide more details with version of sling mock you are using?
and if you are overrding some of it's dependencies (e.g. 
org.apache.sling.resourceresolver or org.apache.sling.jcr.resource) with other 
versions?

you might also try to move sling-mock test dependency to the top in your 
project POM to avoid conflicting transitive dependency.

stefan

>-Original Message-
>From: Santiago Garcia Pimentel [mailto:santiago.pimen...@netcentric.biz]
>Sent: Friday, April 28, 2017 12:33 PM
>To: users@sling.apache.org
>Subject: sling mocks "Creating resource resolver failed"
>
>Hello,
>
>Im trying to use sling mocks and Im having problems when creating content
>when using the JCR_MOCK.
>
>When trying to create a resource with :
>
>@Rule
>public final SlingContext context = new
>SlingContext(ResourceResolverType.JCR_MOCK);
>
>and
>
>context.create().resource("/content/web", ImmutableMap.of("jcr:title",
>"web"));
>
>I get java.lang.RuntimeException: Creating resource resolver failed.
>   at
>org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolv
>er(SlingContextImpl.java:250)
>   at
>org.apache.sling.testing.mock.sling.context.SlingContextImpl.create(SlingCo
>ntextImpl.java:335)
>
>   …..
>Caused by: org.apache.sling.api.resource.LoginException: Calling bundle
>missing in authentication info
>   at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrProviderStateFactory.c
>reateProviderState(JcrProviderStateFactory.java:129)
>   at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.authe
>nticate(JcrResourceProvider.java:284)
>   at
>org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.authe
>nticate(JcrResourceProvider.java:75)
>   at
>org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.a
>uthenticate(ProviderManager.java:161)
>   at
>org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.g
>etOrCreateProvider(ProviderManager.java:87)
>   at
>org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.a
>uthenticateAll(ProviderManager.java:129)
>   at
>org.apache.sling.resourceresolver.impl.ResourceResolverImpl.createControl(R
>esourceResolverImpl.java:154)
>   at
>org.apache.sling.resourceresolver.impl.ResourceResolverImpl.(Resource
>ResolverImpl.java:116)
>   at
>org.apache.sling.resourceresolver.impl.ResourceResolverImpl.(Resource
>ResolverImpl.java:110)
>   at
>org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.ge
>tResourceResolverInternal(CommonResourceResolverFactoryImpl.java:257)
>   at
>org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.ge
>tAdministrativeResourceResolver(CommonResourceResolverFactoryImpl.java:140)
>   at
>org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getAdmin
>istrativeResourceResolver(ResourceResolverFactoryImpl.java:107)
>   at
>org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolv
>er(SlingContextImpl.java:248)
>   ... 27 more
>
>
>
>It seems to be caused by the recent changes in the use of administrative
>resource resolver, and Im not sure how to make it work. Anyone has a tip on
>this?
>
>Santiago García Pimentel| Sr Software Engineer
>Netcentric Ibérica SLU
>M: +34687915463
>santiago.pimen...@netcentric.biz  | www.netcentric.biz



sling mocks "Creating resource resolver failed"

2017-04-28 Thread Santiago Garcia Pimentel
Hello,

Im trying to use sling mocks and Im having problems when creating content when 
using the JCR_MOCK.

When trying to create a resource with :

@Rule
public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);

and 

context.create().resource("/content/web", ImmutableMap.of("jcr:title", "web"));

I get java.lang.RuntimeException: Creating resource resolver failed.
at 
org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolver(SlingContextImpl.java:250)
at 
org.apache.sling.testing.mock.sling.context.SlingContextImpl.create(SlingContextImpl.java:335)

…..
Caused by: org.apache.sling.api.resource.LoginException: Calling bundle missing 
in authentication info
at 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrProviderStateFactory.createProviderState(JcrProviderStateFactory.java:129)
at 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.authenticate(JcrResourceProvider.java:284)
at 
org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.authenticate(JcrResourceProvider.java:75)
at 
org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.authenticate(ProviderManager.java:161)
at 
org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.getOrCreateProvider(ProviderManager.java:87)
at 
org.apache.sling.resourceresolver.impl.providers.stateful.ProviderManager.authenticateAll(ProviderManager.java:129)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.createControl(ResourceResolverImpl.java:154)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.(ResourceResolverImpl.java:116)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.(ResourceResolverImpl.java:110)
at 
org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.getResourceResolverInternal(CommonResourceResolverFactoryImpl.java:257)
at 
org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.getAdministrativeResourceResolver(CommonResourceResolverFactoryImpl.java:140)
at 
org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getAdministrativeResourceResolver(ResourceResolverFactoryImpl.java:107)
at 
org.apache.sling.testing.mock.sling.context.SlingContextImpl.resourceResolver(SlingContextImpl.java:248)
... 27 more



It seems to be caused by the recent changes in the use of administrative 
resource resolver, and Im not sure how to make it work. Anyone has a tip on 
this?

Santiago García Pimentel| Sr Software Engineer
Netcentric Ibérica SLU
M: +34687915463
santiago.pimen...@netcentric.biz  | www.netcentric.biz



RE: i18n json resource files with Sling-Initial-Content (was: Sling pipes release)

2017-04-28 Thread Stefan Seifert
i think it is currently not possible to deploy json-file bases i18n resources 
with Sling-Initial-Content.
as described in [1] the json file node nt:file needs an additional mixin 
mix:language for the language code.
and this is not possible to define with or without ignoreImportProviders=json 
currently.

i would be also very interested to support i18n json files with 
Sling-Initial-Content, but i think we have to improve the content loader 
mechanism for this.

stefan

[1] 
https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html#json-file-based



>-Original Message-
>From: Bertrand Delacretaz [mailto:bdelacre...@apache.org]
>Sent: Friday, April 28, 2017 9:43 AM
>To: users
>Subject: Re: Sling pipes release
>
>On Fri, Apr 28, 2017 at 12:28 AM, Correia
> wrote:
>> ...The "ignoreImportProviders=json" is not a solution because I use JSON
>for
>> all my content...
>
>That option is per path, so I suppose if you isolate those .json files
>in a specific path that should work - but maybe that prevents you from
>creating the structure that the i18n bundle needs?
>
>Worst case, using a JCR SystemView XML file should work but maybe
>that's inconvenient to generate and edit.
>
>-Bertrand



Re: Sling pipes release

2017-04-28 Thread Bertrand Delacretaz
On Fri, Apr 28, 2017 at 12:28 AM, Correia
 wrote:
> ...The "ignoreImportProviders=json" is not a solution because I use JSON for
> all my content...

That option is per path, so I suppose if you isolate those .json files
in a specific path that should work - but maybe that prevents you from
creating the structure that the i18n bundle needs?

Worst case, using a JCR SystemView XML file should work but maybe
that's inconvenient to generate and edit.

-Bertrand