AnsweredAssumed Answered

Node service

Question asked by aznk on Feb 7, 2007
Latest reply on Feb 8, 2007 by aznk
Hi,

I'm just trying to perform a query on nodes to get its properties. I looked at the sdk web service samples, and tried with this code :

public class Tag extends SamplesBase
{
   static FacesContext context = FacesContext.getCurrentInstance();
   static NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();

   //static NodeService nodeService;
   static StoreRef storeRef;
   
    public static void main(String[] args)
        throws Exception
    {
        // Start the session
        AuthenticationUtils.startSession(USERNAME, PASSWORD);
       
        try
        {       
            // Make sure smaple data has been created
            createSampleData();
           
            NodeRef nodeRef = nodeService.getRootNode(storeRef);
           
            NodeRef categoryRef = (NodeRef)nodeService.getProperty(nodeRef, QName.createQName("{extension.tags}", "tags"));
        }
        finally
        {
            // End the session
            AuthenticationUtils.endSession();
        }
    }

but I can't make it work, I guess because I can't initialize NodeService, in this case I get this exception :
java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
   at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:47)
   at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:77)
   at org.alfresco.web.bean.repository.Repository.getServiceRegistry(Repository.java:404)
   at org.alfresco.sample.webservice.Tag.<clinit>(Tag.java:61)
Exception in thread "main"

Any help is much appreciated.

Outcomes