Jahia Dev Forum > Getting Exception...

0 (0 Good)
0 (0 Bad)

Getting Exception when trying to use <jcr:sort> tag

by  abhinitb »  2013/04/01 10:59

Hi,

 

I am using the <jcr:sort> tag in my jsp. My requirement is to sort all the nodes on the basis of date. But I am getting NullPointer Exception for this. The list is an ArrayList of JCRNodeWrapper objects. I am able to printit in my JSP in order to validate it. But when, I pass it to the <jcr:sort< tag, it throws an excpetion. Any pointers ?

Caan anyone suggest a solution for this.

 

Thanks in advance.

 

Best Regards,

Abhinit

  • Getting Exception when trying to use <jcr:sort> tag
    2013/04/01 10:59

    abhinitb <p> Hi,</p> <p> &nbsp;</p> <p> I am using the &lt;jcr:sort&gt; tag in my jsp. My requirement is to sort all the nodes on the basis of date. But I am getting NullPointer Exception for this. The list is an ArrayList of JCRNodeWrapper objects. I am able to printit in my JSP in order to validate it. But when, I pass it to the &lt;jcr:sort&lt; tag, it throws an excpetion. Any pointers ?</p> <p> Caan anyone suggest a solution for this.</p> <p> &nbsp;</p> <p> Thanks in advance.</p> <p> &nbsp;</p> <p> Best Regards,</p> <p> Abhinit</p>

  • Number of messages  28
    Registration date Apr 1, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Getting Exception when trying to use <jcr:sort> tag

    by  namitgupta »  2013/04/02 11:20

    Hi,

     

    I am not sure about your content retrieval method. However, if you are using JCR-SQL for content retrieval then you can simply sort the nodes based on the created/modified date. 

    Example: SELECT * FROM [jnt:article] order by [jcr:created] desc

     

    Regards,

    Namit

  • Re: Getting Exception when trying to use <jcr:sort> tag
    2013/04/02 11:20

    namitgupta <p> Hi,</p> <p> &nbsp;</p> <p> I am not sure about your content retrieval method. However, if you are using JCR-SQL for content retrieval then you can simply sort the nodes based on the created/modified date.&nbsp;</p> <p> Example:&nbsp;SELECT * FROM [jnt:article] order by [jcr:created] desc</p> <p> &nbsp;</p> <p> Regards,</p> <p> Namit</p>

  • Number of messages  36
    Registration date Apr 2, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Getting Exception when trying to use <jcr:sort> tag

    by  abhinitb »  2013/04/03 07:31

    Hi Namit,

     

    Actually I am fetching different kind of nodes by different queries which are already sorted with the help of query. Now, I want to merge all these nodes and sort them as a single set so that all these nodes are together sorted datewise.

    When I tried using the jcr:sort tag, it is giving an exception. 

    Best Regards,

    Abhinit

  • Re: Re: Getting Exception when trying to use <jcr:sort> tag
    2013/04/03 07:31

    abhinitb <p> Hi Namit,</p> <p> &nbsp;</p> <p> Actually I am fetching different kind of nodes by different queries which are already sorted with the help of query. Now, I want to merge all these nodes and sort them as a single set so that all these nodes are together sorted datewise.</p> <p> When I tried using the jcr:sort tag, it is giving an exception.&nbsp;</p> <p> Best Regards,</p> <p> Abhinit</p>

  • Number of messages  28
    Registration date Apr 3, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag

    by  namitgupta »  2013/04/04 04:13

    Hi,

    I think we can apply JCR:sort only to a homogenous list of JCR objects. In your case, the list contains nodes of different types.

    I feel that sorting can be done using a standard Java comparator in this case.

     

    Regards,

    Namit

  • Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag
    2013/04/04 04:13

    namitgupta <p> Hi,</p> <p> I think we can apply JCR:sort only to a homogenous list of JCR objects. In your case, the list contains nodes of different types.</p> <p> I feel that sorting can be done using a standard Java comparator in this case.</p> <p> &nbsp;</p> <p> Regards,</p> <p> Namit</p>

  • Number of messages  36
    Registration date Apr 4, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag

    by  abhinitb »  2013/04/04 12:59

    That's what I did while posting this query :)

    Anyways thanks.

     

    Best Regards,

    Abhinit

  • Re: Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag
    2013/04/04 12:59

    abhinitb <p> That&#39;s what I did while posting this query :)</p> <p> Anyways thanks.</p> <p> &nbsp;</p> <p> Best Regards,</p> <p> Abhinit</p>

  • Number of messages  28
    Registration date Apr 4, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Getting Exception when trying to use <jcr:sort> tag

    by  pap@commaro.com »  2013/04/04 21:14

    Hello,

    on which code line exactly did you get the NullPointerException ?

    Regards,
    Benjamin

    Benjamin Papez (pap@commaro.com)

    Number of messages  220
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Getting Exception when trying to use <jcr:sort> tag

    by  abhinitb »  2013/04/05 09:34

    Hi Benjamin,

    Please find below the partial stack trace :

     

    2013-04-01 12:33:13,443: WARN  [http-8080-1] org.jahia.services.render.filter.TemplateScriptFilter: Error including the content of the template 'Path dispatch : /modules/MEP_Latest_Updates/jnt_meplatestupdatesjson/html/meplatestupdatesjson.jsp'. Cause: null
    java.lang.NullPointerException
    at java.util.ArrayList.<init>(Unknown Source)
    at org.jahia.taglibs.jcr.node.JCRSortTag.doEndTag(JCRSortTag.java:97)
    at org.apache.jsp.modules.MEP_005fLatest_005fUpdates.jnt_005fmeplatestupdatesjson.html.meplatestupdatesjson_jsp._jspx_meth_jcr_005fsort_005f0(meplatestupdatesjson_jsp.java:286)
    at org.apache.jsp.modules.MEP_005fLatest_005fUpdates.jnt_005fmeplatestupdatesjson.html.meplatestupdatesjson_jsp._jspService(meplatestupdatesjson_jsp.java:103)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     
    Best Regards,
    Abhinit
  • Re: Re: Getting Exception when trying to use <jcr:sort> tag
    2013/04/05 09:34

    abhinitb <p> Hi Benjamin,</p> <p> Please find below the partial stack trace :</p> <p> &nbsp;</p> <div> 2013-04-01 12:33:13,443: WARN &nbsp;[http-8080-1] org.jahia.services.render.filter.TemplateScriptFilter: Error including the content of the template &#39;Path dispatch : /modules/MEP_Latest_Updates/jnt_meplatestupdatesjson/html/meplatestupdatesjson.jsp&#39;. Cause: null</div> <div> java.lang.NullPointerException</div> <div> at java.util.ArrayList.&lt;init&gt;(Unknown Source)</div> <div> at org.jahia.taglibs.jcr.node.JCRSortTag.doEndTag(JCRSortTag.java:97)</div> <div> at org.apache.jsp.modules.MEP_005fLatest_005fUpdates.jnt_005fmeplatestupdatesjson.html.meplatestupdatesjson_jsp._jspx_meth_jcr_005fsort_005f0(meplatestupdatesjson_jsp.java:286)</div> <div> at org.apache.jsp.modules.MEP_005fLatest_005fUpdates.jnt_005fmeplatestupdatesjson.html.meplatestupdatesjson_jsp._jspService(meplatestupdatesjson_jsp.java:103)</div> <div> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)</div> <div> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</div> <div> &nbsp;</div> <div> Best Regards,</div> <div> Abhinit</div>

  • Number of messages  28
    Registration date Apr 5, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag

    by  pap@commaro.com »  2013/04/05 10:14

    Hello Abhinit,

    we will make the tag more fail-safe to prevent the NullPointerException. The problem however is in the list parameter you pass into the tag. It is either null or not of type Collection or Iterator.

    What are you passing as list parameter into the tag and how?

    Regards,
    Benjamin

    Benjamin Papez (pap@commaro.com)

    Number of messages  220
    Registration date
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page