3 Replies Latest reply on Sep 21, 2004 9:40 PM by Ben Wang

    NullPointerException, Map and values().iterator()

    Clinton Parham Newbie

      I'm trying to figure this one out:

      Person person = new Person();
      person.setHobbies(new HashMap());
      Iterator i = person.getHobbies().values().iterator();
      
      Util.getClusterCache().putObject("/test", person);
      person = (Person)Util.getClusterCache().getObject("/test");
      
      i = person.getHobbies().values().iterator();
      ...
      public static synchronized TreeCacheAop getClusterCache(){
       if(treeCache == null){
       try {
       treeCache = new TreeCacheAop();
       PropertyConfigurator config = new PropertyConfigurator(); // configure tree cache.
       config.configure(treeCache, "META-INF/replSync-service.xml");
       treeCache.startService();
       } catch (Exception e) {
       traceLog.fatal("Error while initializing JBoss cache", e);
       }
       }
       return treeCache;
      }


      Why does line 8 (.values.iterator()) cause a NullPointerException but line 3 doesn't?