我有一个将输入流写入文件的服务。之前我正在将文件写入本地机器然后它工作正常。但是现在我希望我的服务将输入流写入hdfs中的文件。
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);
部署代码后...当我使用url点击服务时,我遇到错误。
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).
ServiceAction.java:30行基本上是UserGroupInformation realUser = UserGroupInformation.createRemoteUser("mapr");