title: How to use memcached client in java web application specially in Struts 2 which is running on tomcat?
body: <pre><code>public class MemCacheClientInit {
      static MemcachedClient mcc = null;
      static String ipAdderss = "127.0.0.1";
      static int port = 11211;
      public static boolean isMemCacheInit = false;
  
      public static MemcachedClient getInstance() {
          if (mcc == null) {
              try {
                  isMemCacheInit = initMemServer();
                  mcc = new MemcachedClient(new InetSocketAddress(ipAdderss, port));
              }
              catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
          return mcc;
      }
  
      private static boolean initMemServer() {
          try {
              String[] servers = {"localhost:11211",};
              Integer[] weights = {1};
              SchoonerSockIOPool pool = SchoonerSockIOPool.getInstance();
              pool.setServers(servers);
              pool.setWeights(weights);
              pool.setInitConn(5);
              pool.setMinConn(5);
              pool.setMaxConn(250);
              pool.setMaxIdle(1000 * 60 * 60 * 6);
              pool.initialize();
              pool.setHashingAlg(SchoonerSockIOPool.NEW_COMPAT_HASH);
              return true;
          }
  
          catch (Exception ex) {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>I am running this code directly from my DAO and setting objects in the Memcache, in the above code snippet in the <code>InitMemServer</code> method while getting instance of <code>SchoonerSockIOPool</code> it is throwing <code>invocationTarget</code> Exception.</p>