Thanks Jan for your reply.

I tried the above syntax you suggested. Still the same null pointer exception I 
got.
I tried the piece of code below. Its working fine.
Is it ok?
--------------------------------------------------------------
public class NodeCreate extends MgnlCommand{

        @Override
        public boolean execute(final Context context) throws Exception {
                try {
                        
                        MgnlContext.doInSystemContext(new MgnlContext.VoidOp() {
                    @Override
                    public void doExec() {
                                    createContentNode();
                    }
                });
                        
                    } catch (Exception e) {
                        System.out.println(e.getMessage());
                    return false;
            }
                        return true;
        }
        


protected void createContentNode() {
        System.out.println("My Command Class is getting called");
        Session session;
        try {
                session = MgnlContext.getJCRSession("data");
                Node node = session.getNode("/MyXml");
                System.out.println(node.getName());
                
                Node myNode = node.addNode("myNode",MgnlNodeType.NT_CONTENT);
        myNode.setProperty("value", "myPropVal");
        session.save();
        } catch (LoginException e) {
                System.out.println(e.getMessage());
        } catch (RepositoryException e) {
                System.out.println(e.getMessage());
        }       
}
}

-- 
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=45380f8c-f516-4c03-b3fe-054255eb067e


----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to