AnsweredAssumed Answered

AVMRemote is null, if used outside ServletContext

Question asked by kapil.k@globallogic.com on Feb 23, 2008
Latest reply on Feb 28, 2008 by rivetlogic
How do I write a standalone (outside servlet context) client java program, that can list the avm repo directory map?

I used the repoDirMap.jsp from RivetLogic as a starting point? The JSP works fine (from within the servlet context), but when i try to write a standaline Java program I get AVMRemote as null (e.g. on calling: List list = avmRemote.getStores());

Code:
public class AVMDemo {
   public static void main(String[] args) throws Exception {
      String avmPath = "v:\\alfrescowww–admin\\VERSION\\v-1\\DATA\\www\\avm_webapps\\ROOT\\";

      
      String mountPoint = "v:\\";
       final JNDIPath jndiPath = new JNDIPath(mountPoint, avmPath);
       avmPath = jndiPath.getAvmPath();
       System.out.println("avmPath: " + avmPath);

AVMFileDirContext.getAVMRemote();

      List list = avmRemote.getStores();  // avmRemot is Null here
      Map<String, AVMNodeDescriptor> nodes = avmRemote.getDirectoryListing(-1, avmPath);
              
         for (Map.Entry<String, AVMNodeDescriptor> node : nodes.entrySet()) {
            String nodeKey = node.getKey();

            AVMNodeDescriptor nodeValue = node.getValue();
           
            if (nodeValue.isDirectory() ) {
               System.out.println("Directory: ");
               System.out.println("/" + nodeKey + "<br>");

//               repoDirMap(path + "/" + nodeKey, "", pageContext, out);
            }
              
         }
      
   }
}

OUTPUT:
avmPath: alfrescowww–admin:/www/avm_webapps/ROOT/
Exception in thread "main" java.lang.NullPointerException
   at com.gl.alfresco.demo.AVMDemo.main(AVMDemo.java:37)

I think the issue is in getting AVMRemote initialized correctly.
Please advise how to go about this.

Thanks,
Kapil

Outcomes