[ 
https://issues.apache.org/jira/browse/JCR-2581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12993664#comment-12993664
 ] 

pearms commented on JCR-2581:
-----------------------------

We are running into the same issue and it's forcing some difficult workarounds. 
 The condition we are seeing is identical - when the call 
ItemManager.getDefinition is called from the above code with a Version 
NodeState this particular call cause a NPE:

        // get child node entry
        ChildNodeEntry cne = parentState.getChildNodeEntry(state.getNodeId());  
// CNE is null at this point and cause NPE further down
        NodeTypeRegistry ntReg = 
session.getNodeTypeManager().getNodeTypeRegistry();

I'm still not sure why the Version node is not part of the VersionHistory 
childEntries at this point.  This one is killing us - any help would be 
appreciated!!!

> Get NPE when custom node was updated
> ------------------------------------
>
>                 Key: JCR-2581
>                 URL: https://issues.apache.org/jira/browse/JCR-2581
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>    Affects Versions: 2.0.0
>         Environment: Windows XP
> JDK 1.5.12
> JBoss 4.2.3
>            Reporter: Stas
>
> I try to upgrade jackrabbit version in my project from 1.6 to 2.0. Some 
> things from 2.0 are very usable. Thank you all for your job. But after 
> transition on new version i get "magic" problems. I often catch NPE exception 
> from inside jackrabbit api. After some investigations and tests i had found 
> one of many problems.
> What i do in my test?
> I declare custom node type in cnd file. Then register it.
>  [my:test] > nt:folder
>   orderable
>   - myp:html (string)
>   = ''
>     autocreated
>     copy
> Call method create.
> private void testCreate(String name, String html, CredentialsTO credentials){
>         Node docRootNode;
>         Session session = null;
>         try {
>             session = getSession(credentials);
>             docRootNode = session.getRootNode();
>             Node testNode = docRootNode.addNode(name, "my:test");
>             testNode.setProperty("myp:html", html);
>             testNode.addMixin("mix:versionable");
>             session.save();
>             
> session.getWorkspace().getVersionManager().checkin(testNode.getPath());
>         } catch (Exception e) {
>             //do something
>         } finally {
>             logout(session);
>         }
>     }
> Then do update.
>  private void testUpdate(String name, String html, CredentialsTO credentials){
>         Session session = null;
>         Node docRootNode;
>         try {
>             session = getSession(credentials);
>             docRootNode = session.getRootNode();
>             Node testNode =  docRootNode.getNode(name);
>             
> session.getWorkspace().getVersionManager().checkout(testNode.getPath());
>             testNode.setProperty("myp:html", html);
>             session.save();
>             
> session.getWorkspace().getVersionManager().checkin(testNode.getPath());
>         }  catch (Exception e) {
>             // do something
>         } finally {
>             logout(session);
>         }
>     }
> After last checkin in update method i always catch NullPointerException. I 
> had connected src of jcr and jackrabbit and done some debug. This is method 
> which throw exception in org.apache.jackrabbit.core.ItemManager.
>  private boolean canRead(ItemData data, Path path) throws 
> AccessDeniedException, RepositoryException {
>         // JCR-1601: cached item may just have been invalidated
>         ItemState state = data.getState();
>         if (state == null) {
>             throw new InvalidItemStateException(data.getId() + ": the item 
> does not exist anymore");
>         }
>         if (state.getStatus() == ItemState.STATUS_NEW &&
>                 !data.getDefinition().isProtected()) {  // THIS IS RIGHT 
> PLACE data.getDefinition() = null
>             // NEW items can always be read as long they have been added
>             // through the API and NOT by the system (i.e. protected props).
>             return true;
>         } else {
>             return (path == null) ?
>                     canRead(data.getId()) :
>                     session.getAccessManager().canRead(path);
>         }
>     }
> I don't understand when and why definition in NodeData can be null? This is 
> my fault, wrong settings of repository or bug of jackrabbit?

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

        

Reply via email to