You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Dascalita Dragos <dd...@gmail.com> on 2012/08/21 21:59:44 UTC

JcrResourceListener : this.resourceResolver.adaptTo(Session.class) is null

Hello,
I'm trying to understand the cause of the error in the title.My Sling
version is built from Rev. 1375551, but this error was happening
previously.  It's not happening when running Sling in my local machine, but
it's happening when I'm running it on a Cent OS 6.2 machine, with java
version:

java version "1.6.0_22" , OpenJDK Runtime Environment (IcedTea6 1.10.6)
(rhel-1.25.1.10.6.el5_8-x86_64) , OpenJDK 64-Bit Server VM (build 20.0-b11,
mixed mode)


*ERROR* [FelixStartLevel] org.apache.sling.jcr.resource
[org.apache.sling.jcr.resource.internal.JcrResourceListener] The activate
method has thrown an exception (java.lang.NullPointerException)
java.lang.NullPointerException

at
org.apache.sling.jcr.resource.internal.JcrResourceListener.activate(JcrResourceListener.java:133)

The code goes into ResourceResolverImpl.getSession().
this.factory.getRootProviderEntry().adaptTo(this.context,
Session.class); returns a null session.

It seems like final Iterator<Adaptable> i =
this.adaptableProviders.getProviders(ctx, null); (within
RootResourceProviderEntry.java class) returns an empty list, and therefore
the result is null, causing the session in JcrResourceListener to be null
and then the NPE.

I'm trying to understand how come SortedProvidersList.getProviders() is
empty and if providers can be configured, or what can I do to workaround
this issue.


Thanks for your help,

Dragos Dascalita Haut

Re: JcrResourceListener : this.resourceResolver.adaptTo(Session.class) is null

Posted by Chetan Mehrotra <ch...@gmail.com>.
Done https://issues.apache.org/jira/browse/SLING-2573

Chetan Mehrotra

Re: JcrResourceListener : this.resourceResolver.adaptTo(Session.class) is null

Posted by Felix Meschberger <fm...@adobe.com>.
May I ask you to raise a JIRA issue ? Thank you very much.

Regards
Felix

Am 22.08.2012 um 19:26 schrieb Chetan Mehrotra:

> I am also facing the same issue where JcrResourceListener activate is
> failing with a NPE. On debugging it appears that session instance returned
> is null. Which happens because 'requiredFactories' in
> RootResourceProviderEntry.loginToRequiredFactories [1] empty.
> 
> This is probably happening because of a startup order.
> ResourceResolverFactoryImpl which is responsible for setting the
> requiredFactories in RootResourceProviderEntry has an Optional, Multiple
> dependency on ResourceProviderFactory. So it can happen that when a
> ResourceResolverFactory is published in OSGi SR it does not have any
> reference to ResourceProviderFactory and in that time JcrResourceListener
> tries to access it. May be the dependency should be set to Required,
> Multiple to ensure that ResourceResolverFactoryImpl is properly initialized.
> 
> Chetan Mehrotra
> [1]
> org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry.loginToRequiredFactories(ResourceResolverContext)
> 
> On Wed, Aug 22, 2012 at 2:02 AM, Dascalita Dragos <dd...@gmail.com>wrote:
> 
>> Hi,
>> I actually managed to reproduce the error on my local machine as well, by
>> stopping and starting Apache Sling JCR Resource Resolver
>> org.apache.sling.jcr.resource<
>> http://hendrix.local.adobe.com:8080/system/console/bundles/36>
>> bundle.
>> 
>> Regards,
>> Dragos Dascalita Haut
>> 
>> On Tue, Aug 21, 2012 at 10:59 PM, Dascalita Dragos <ddragosd@gmail.com
>>> wrote:
>> 
>>> Hello,
>>> I'm trying to understand the cause of the error in the title.My Sling
>>> version is built from Rev. 1375551, but this error was happening
>>> previously.  It's not happening when running Sling in my local machine,
>> but
>>> it's happening when I'm running it on a Cent OS 6.2 machine, with java
>>> version:
>>> 
>>> java version "1.6.0_22" , OpenJDK Runtime Environment (IcedTea6 1.10.6)
>>> (rhel-1.25.1.10.6.el5_8-x86_64) , OpenJDK 64-Bit Server VM (build
>> 20.0-b11,
>>> mixed mode)
>>> 
>>> 
>>> *ERROR* [FelixStartLevel] org.apache.sling.jcr.resource
>>> [org.apache.sling.jcr.resource.internal.JcrResourceListener] The activate
>>> method has thrown an exception (java.lang.NullPointerException)
>>> java.lang.NullPointerException
>>> 
>>> at
>>> 
>> org.apache.sling.jcr.resource.internal.JcrResourceListener.activate(JcrResourceListener.java:133)
>>> 
>>> The code goes into ResourceResolverImpl.getSession().
>> this.factory.getRootProviderEntry().adaptTo(this.context,
>>> Session.class); returns a null session.
>>> 
>>> It seems like final Iterator<Adaptable> i =
>>> this.adaptableProviders.getProviders(ctx, null); (within
>>> RootResourceProviderEntry.java class) returns an empty list, and
>>> therefore the result is null, causing the session in JcrResourceListener
>> to
>>> be null and then the NPE.
>>> 
>>> I'm trying to understand how come SortedProvidersList.getProviders() is
>>> empty and if providers can be configured, or what can I do to workaround
>>> this issue.
>>> 
>>> 
>>> Thanks for your help,
>>> 
>>> Dragos Dascalita Haut
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 


Re: JcrResourceListener : this.resourceResolver.adaptTo(Session.class) is null

Posted by Chetan Mehrotra <ch...@gmail.com>.
I am also facing the same issue where JcrResourceListener activate is
failing with a NPE. On debugging it appears that session instance returned
is null. Which happens because 'requiredFactories' in
RootResourceProviderEntry.loginToRequiredFactories [1] empty.

This is probably happening because of a startup order.
ResourceResolverFactoryImpl which is responsible for setting the
requiredFactories in RootResourceProviderEntry has an Optional, Multiple
dependency on ResourceProviderFactory. So it can happen that when a
ResourceResolverFactory is published in OSGi SR it does not have any
reference to ResourceProviderFactory and in that time JcrResourceListener
tries to access it. May be the dependency should be set to Required,
Multiple to ensure that ResourceResolverFactoryImpl is properly initialized.

Chetan Mehrotra
[1]
org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry.loginToRequiredFactories(ResourceResolverContext)

On Wed, Aug 22, 2012 at 2:02 AM, Dascalita Dragos <dd...@gmail.com>wrote:

> Hi,
> I actually managed to reproduce the error on my local machine as well, by
> stopping and starting Apache Sling JCR Resource Resolver
> org.apache.sling.jcr.resource<
> http://hendrix.local.adobe.com:8080/system/console/bundles/36>
>  bundle.
>
> Regards,
> Dragos Dascalita Haut
>
> On Tue, Aug 21, 2012 at 10:59 PM, Dascalita Dragos <ddragosd@gmail.com
> >wrote:
>
> > Hello,
> > I'm trying to understand the cause of the error in the title.My Sling
> > version is built from Rev. 1375551, but this error was happening
> > previously.  It's not happening when running Sling in my local machine,
> but
> > it's happening when I'm running it on a Cent OS 6.2 machine, with java
> > version:
> >
> > java version "1.6.0_22" , OpenJDK Runtime Environment (IcedTea6 1.10.6)
> > (rhel-1.25.1.10.6.el5_8-x86_64) , OpenJDK 64-Bit Server VM (build
> 20.0-b11,
> > mixed mode)
> >
> >
> > *ERROR* [FelixStartLevel] org.apache.sling.jcr.resource
> > [org.apache.sling.jcr.resource.internal.JcrResourceListener] The activate
> > method has thrown an exception (java.lang.NullPointerException)
> > java.lang.NullPointerException
> >
> > at
> >
> org.apache.sling.jcr.resource.internal.JcrResourceListener.activate(JcrResourceListener.java:133)
> >
> > The code goes into ResourceResolverImpl.getSession().
>  this.factory.getRootProviderEntry().adaptTo(this.context,
> > Session.class); returns a null session.
> >
> > It seems like final Iterator<Adaptable> i =
> > this.adaptableProviders.getProviders(ctx, null); (within
> > RootResourceProviderEntry.java class) returns an empty list, and
> > therefore the result is null, causing the session in JcrResourceListener
> to
> > be null and then the NPE.
> >
> > I'm trying to understand how come SortedProvidersList.getProviders() is
> > empty and if providers can be configured, or what can I do to workaround
> > this issue.
> >
> >
> > Thanks for your help,
> >
> > Dragos Dascalita Haut
> >
> >
> >
> >
> >
> >
> >
> >
>

Re: JcrResourceListener : this.resourceResolver.adaptTo(Session.class) is null

Posted by Dascalita Dragos <dd...@gmail.com>.
Hi,
I actually managed to reproduce the error on my local machine as well, by
stopping and starting Apache Sling JCR Resource Resolver
org.apache.sling.jcr.resource<http://hendrix.local.adobe.com:8080/system/console/bundles/36>
 bundle.

Regards,
Dragos Dascalita Haut

On Tue, Aug 21, 2012 at 10:59 PM, Dascalita Dragos <dd...@gmail.com>wrote:

> Hello,
> I'm trying to understand the cause of the error in the title.My Sling
> version is built from Rev. 1375551, but this error was happening
> previously.  It's not happening when running Sling in my local machine, but
> it's happening when I'm running it on a Cent OS 6.2 machine, with java
> version:
>
> java version "1.6.0_22" , OpenJDK Runtime Environment (IcedTea6 1.10.6)
> (rhel-1.25.1.10.6.el5_8-x86_64) , OpenJDK 64-Bit Server VM (build 20.0-b11,
> mixed mode)
>
>
> *ERROR* [FelixStartLevel] org.apache.sling.jcr.resource
> [org.apache.sling.jcr.resource.internal.JcrResourceListener] The activate
> method has thrown an exception (java.lang.NullPointerException)
> java.lang.NullPointerException
>
> at
> org.apache.sling.jcr.resource.internal.JcrResourceListener.activate(JcrResourceListener.java:133)
>
> The code goes into ResourceResolverImpl.getSession().  this.factory.getRootProviderEntry().adaptTo(this.context,
> Session.class); returns a null session.
>
> It seems like final Iterator<Adaptable> i =
> this.adaptableProviders.getProviders(ctx, null); (within
> RootResourceProviderEntry.java class) returns an empty list, and
> therefore the result is null, causing the session in JcrResourceListener to
> be null and then the NPE.
>
> I'm trying to understand how come SortedProvidersList.getProviders() is
> empty and if providers can be configured, or what can I do to workaround
> this issue.
>
>
> Thanks for your help,
>
> Dragos Dascalita Haut
>
>
>
>
>
>
>
>