You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "David Buchmann (JIRA)" <ji...@apache.org> on 2011/08/12 13:44:27 UTC

[jira] [Created] (JCR-3050) NullPointerException on removing a node acquired from search result

NullPointerException on removing a node acquired from search result
-------------------------------------------------------------------

                 Key: JCR-3050
                 URL: https://issues.apache.org/jira/browse/JCR-3050
             Project: Jackrabbit Content Repository
          Issue Type: Bug
            Reporter: David Buchmann


with a code snipped like the following, i get a NullPointerException in ItemState:

Session s = repo.login(sc,workspace);
QueryManager qm = s.getWorkspace().getQueryManager();
Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
QueryResult r = q.execute();
NodeIterator i = r.getNodes();

Node n = i.nextNode();
n.remove(); // breaks here with NullPointerException

Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
        at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
        at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
        at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3050) NullPointerException on removing a node acquired from search result

Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13290121#comment-13290121 ] 

Alex Parvulescu commented on JCR-3050:
--------------------------------------

backported to 2.4 in rev 1346866.
                
> NullPointerException on removing a node acquired from search result
> -------------------------------------------------------------------
>
>                 Key: JCR-3050
>                 URL: https://issues.apache.org/jira/browse/JCR-3050
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>            Reporter: David Buchmann
>             Fix For: 2.5
>
>
> with a code snipped like the following, i get a NullPointerException in ItemState:
> Session s = repo.login(sc,workspace);
> QueryManager qm = s.getWorkspace().getQueryManager();
> Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
> QueryResult r = q.execute();
> NodeIterator i = r.getNodes();
> Node n = i.nextNode();
> n.remove(); // breaks here with NullPointerException
> Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
>         at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
>         at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
>         at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (JCR-3050) NullPointerException on removing a node acquired from search result

Posted by "Alex Parvulescu (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Parvulescu resolved JCR-3050.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.5

The NPE happens because you re trying to delete the root node.
(Try running the same query and printing the path of the nodes you get)

I've fixed the NPE, but your scenario is still not going to work as you cannot delete the root node. You'll get a ConstraintViolationException: "Cannot remove root node."

Fixed in revision #1240198.
                
> NullPointerException on removing a node acquired from search result
> -------------------------------------------------------------------
>
>                 Key: JCR-3050
>                 URL: https://issues.apache.org/jira/browse/JCR-3050
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>            Reporter: David Buchmann
>             Fix For: 2.5
>
>
> with a code snipped like the following, i get a NullPointerException in ItemState:
> Session s = repo.login(sc,workspace);
> QueryManager qm = s.getWorkspace().getQueryManager();
> Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
> QueryResult r = q.execute();
> NodeIterator i = r.getNodes();
> Node n = i.nextNode();
> n.remove(); // breaks here with NullPointerException
> Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
>         at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
>         at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
>         at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3050) NullPointerException on removing a node acquired from search result

Posted by "Julian Reschke (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Reschke updated JCR-3050:
--------------------------------

    Component/s: jackrabbit-jcr2spi
    
> NullPointerException on removing a node acquired from search result
> -------------------------------------------------------------------
>
>                 Key: JCR-3050
>                 URL: https://issues.apache.org/jira/browse/JCR-3050
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>            Reporter: David Buchmann
>
> with a code snipped like the following, i get a NullPointerException in ItemState:
> Session s = repo.login(sc,workspace);
> QueryManager qm = s.getWorkspace().getQueryManager();
> Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
> QueryResult r = q.execute();
> NodeIterator i = r.getNodes();
> Node n = i.nextNode();
> n.remove(); // breaks here with NullPointerException
> Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
>         at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
>         at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
>         at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3050) NullPointerException on removing a node acquired from search result

Posted by "Alex Parvulescu (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13199761#comment-13199761 ] 

Alex Parvulescu commented on JCR-3050:
--------------------------------------

hi, you are welcome :)

by the way, you're not supposed to close the issue ;) just leave it as 'resolved' and when it ships it will turn into 'closed'. 

see more here http://jackrabbit.apache.org/issue-tracker.html

                
> NullPointerException on removing a node acquired from search result
> -------------------------------------------------------------------
>
>                 Key: JCR-3050
>                 URL: https://issues.apache.org/jira/browse/JCR-3050
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>            Reporter: David Buchmann
>             Fix For: 2.5
>
>
> with a code snipped like the following, i get a NullPointerException in ItemState:
> Session s = repo.login(sc,workspace);
> QueryManager qm = s.getWorkspace().getQueryManager();
> Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
> QueryResult r = q.execute();
> NodeIterator i = r.getNodes();
> Node n = i.nextNode();
> n.remove(); // breaks here with NullPointerException
> Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
>         at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
>         at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
>         at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3050) NullPointerException on removing a node acquired from search result

Posted by "Alex Parvulescu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Parvulescu updated JCR-3050:
---------------------------------

    Fix Version/s: 2.4.2
         Assignee: Alex Parvulescu
    
> NullPointerException on removing a node acquired from search result
> -------------------------------------------------------------------
>
>                 Key: JCR-3050
>                 URL: https://issues.apache.org/jira/browse/JCR-3050
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>            Reporter: David Buchmann
>            Assignee: Alex Parvulescu
>             Fix For: 2.4.2, 2.5
>
>
> with a code snipped like the following, i get a NullPointerException in ItemState:
> Session s = repo.login(sc,workspace);
> QueryManager qm = s.getWorkspace().getQueryManager();
> Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
> QueryResult r = q.execute();
> NodeIterator i = r.getNodes();
> Node n = i.nextNode();
> n.remove(); // breaks here with NullPointerException
> Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
>         at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
>         at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
>         at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (JCR-3050) NullPointerException on removing a node acquired from search result

Posted by "David Buchmann (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Buchmann closed JCR-3050.
-------------------------------


oh, ok. guess with the right exception i will understand what i do wrong :-)

actually the root node is reported as something else than nt:unstructured, so it was not so obvious to me.

thanks for the cleanup
                
> NullPointerException on removing a node acquired from search result
> -------------------------------------------------------------------
>
>                 Key: JCR-3050
>                 URL: https://issues.apache.org/jira/browse/JCR-3050
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-jcr2spi
>            Reporter: David Buchmann
>             Fix For: 2.5
>
>
> with a code snipped like the following, i get a NullPointerException in ItemState:
> Session s = repo.login(sc,workspace);
> QueryManager qm = s.getWorkspace().getQueryManager();
> Query q = qm.createQuery("SELECT * FROM [nt:unstructured]", Query.JCR_SQL2);
> QueryResult r = q.execute();
> NodeIterator i = r.getNodes();
> Node n = i.nextNode();
> n.remove(); // breaks here with NullPointerException
> Exception in thread "main" java.lang.NullPointerException                                                                                                                                                                                   
>         at org.apache.jackrabbit.jcr2spi.state.ItemState.getParent(ItemState.java:210)                                                                                                                                                      
>         at org.apache.jackrabbit.jcr2spi.operation.Remove.create(Remove.java:98)                                                                                                                                                            
>         at org.apache.jackrabbit.jcr2spi.ItemImpl.remove(ItemImpl.java:306) 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira