title: exception in java
body: <p>private String getEmailTemplateWithActualValueForAccount(String template, Account account) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {</p>
  
  <pre><code>    Map&lt;String,String&gt; map = new HashMap&lt;String, String&gt;(); 
      List&lt;String&gt; listTags = new ArrayList&lt;String&gt;();
      Map&lt;Method, String&gt; methodList = new HashMap&lt;Method, String&gt;();
  
      int startIndex=0;
      int endIndex=0;
  
      for(int i=0; i&lt;template.length(); i++)
      {
          char ch = template.charAt(i);
          if(ch=='$')
              startIndex = i+1;
          if(ch=='#')
          {
              endIndex = i+1;
              listTags.add(template.substring(startIndex,endIndex));
          }
  
      }
  
      Method[] methods = Account.class.getMethods();
  
      for (Method method : methods) {
          String methodName = method.getName();
          if(method.getName().startsWith("get"))
          {
              methodList.put(method, methodName.substring(3,methodName.length()).toUpperCase()+"#");
          }
      }
  
      Set&lt;Method&gt; methodKeySet = methodList.keySet();
      for (Method method : methodKeySet) {
          for (String string : listTags) {
  
              if(methodList.get(method).equals(string))
              {
                  try{
                      Object obj = method.invoke(account, null);
                      if(obj!=null)
                          map.put(string, obj.toString());
                  }catch(NullPointerException e){
                  }
              }
          }
      } 
  
      final StringBuilder list = new StringBuilder( "\\$(" );
      for( final String key: map.keySet() )
      { 
          list.append( key ); 
          list.append( "|" ); 
      }
      list.append( "[^\\s\\S])" );
      Pattern pattern = Pattern.compile( list.toString() );
      Matcher matcher = pattern.matcher( template );
  
  
      final StringBuffer stringBuffer = new StringBuffer();
      while( matcher.find() ){
          final String string = matcher.group( 1 );
          matcher.appendReplacement( stringBuffer, map.get( string )); 
      }
      matcher.appendTail( stringBuffer );
  
      return stringBuffer.toString();
  }
  </code></pre>
  
  <p>I got an exception at line of code "Object obj = method.invoke(account, null);"
  Code is perfectly working but as this code is in scheduler it will create an log at every 20 second on jboss server.</p>