title: Tomcat application is giving java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.UserGroupInformation error
body: <p>I have a service which writes input stream to a file. Earlier I was writing the file to local machine then it was working fine. But now I want to my service to write input stream to a file in hdfs.</p>
  
  <pre><code>Configuration conf = new Configuration();
  
  UserGroupInformation realUser =  UserGroupInformation.createRemoteUser("mapr");
  
  UserGroupInformation.setLoginUser(realUser);
  FileSystem fs = FileSystem.get(conf)
  String fileWriteAt = "maprfs:///mapr/silver1cluster/"+filePath;
  Path outpath= new Path(fileWriteAt);
  OutputStream os = fs.create(outpath);
  InputStream is = new BufferedInputStream(inputStream);
  IOUtils.copyBytes(is, os, conf);
  </code></pre>
  
  <p>After deploying the code ...when I m hitting the service with with the url i m getting below error.</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.UserGroupInformation
      com.api.service.ServiceAction.saveFile(ServiceAction.java:30)
      com.api.service.FileHandling.uploadFile(FileHandling.java:51).
  </code></pre>
  
  <p>ServiceAction.java: 30 line is basically <code>UserGroupInformation realUser = UserGroupInformation.createRemoteUser("mapr");</code></p>