I have a spring boot application that is being exported as a .zip file and used as a lambda function. I'm generating a file and adding content to it.
file = new File(fileName);// fileName is just a String.txt
context.getLogger().log("File Path1: "+file.getAbsolutePath());
FileUtils.writeLines(file, failedMessages); //failedMessages is a List<String>
context.getLogger().log("File Path2: "+file.getAbsolutePath());
The logs:
File Path1: /var/task/Platform_Status_Failed_2022_09_09.txt
Exception caught java.io.FileNotFoundException: Platform_Status_Failed_2022_09_09.txt (Read-only file system)
Not sure how to fix this. Should I create a temporary folder and save the file and write to that path or is there any other simpler fix?
Update:
Tried using the /tmp path of lambda. As per my logs, it seems that the contents are written to this location but when I'm trying to upload this file to S3 I get an Exception:
Unable to calculate MD5 hash: /tmp/Platform_Status_Failed_2022_09_09.txt (No such file or directory): java.lang.BootstrapMethodError
java.lang.BootstrapMethodError: Unable to calculate MD5 hash: /tmp/Platform_Status_Failed_2022_09_09.txt (No such file or directory)
at com.paytmmoney.bo.equities.lambda.handler.LambdaMethodHandler.uploadToS3(LambdaMethodHandler.java:171)
at com.paytmmoney.bo.equities.lambda.handler.LambdaMethodHandler.uploadFileToS3(LambdaMethodHandler.java:88)
at com.paytmmoney.bo.equities.lambda.handler.LambdaMethodHandler.handleRequest(LambdaMethodHandler.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: com.amazonaws.SdkClientException: Unable to calculate MD5 hash: /tmp/Platform_Status_Failed_2022_09_09.txt (No such file or directory)
at com.amazonaws.services.s3.AmazonS3Client.getInputStream(AmazonS3Client.java:1849)
at com.amazonaws.services.s3.AmazonS3Client.uploadObject(AmazonS3Client.java:1767)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1746)
at com.paytmmoney.bo.equities.lambda.handler.LambdaMethodHandler.uploadToS3(LambdaMethodHandler.java:159)
... 6 more
Caused by: java.io.FileNotFoundException: /tmp/Platform_Status_Failed_2022_09_09.txt (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at com.amazonaws.util.Md5Utils.computeMD5Hash(Md5Utils.java:97)
at com.amazonaws.util.Md5Utils.md5AsBase64(Md5Utils.java:104)
at com.amazonaws.services.s3.AmazonS3Client.getInputStream(AmazonS3Client.java:1845)
... 9 more
Related
I am trying to copy files between two mapr clusters
hadoop distcp maprfs:///path/to/source/hive/table maprfs:///path/to/destination/hive/table
The source table has some data, but the destination table is empty. I have just used the create table command in the destination.
but for the above distcp command, i get
java.io.FileNotFoundException: Requested file maprfs:/var/mapr/cluster/yarn/rm/staging/some_user/.staging/job_1528383939830_608130 does not exist.
at com.mapr.fs.MapRFileSystem.getMapRFileStatus(MapRFileSystem.java:1262)
at com.mapr.fs.MapRFileSystem.getFileStatus(MapRFileSystem.java:927)
at com.mapr.fs.MFS.getFileStatus(MFS.java:151)
at org.apache.hadoop.fs.AbstractFileSystem.resolvePath(AbstractFileSystem.java:467)
at org.apache.hadoop.mapred.YARNRunner.createApplicationSubmissionContext(YARNRunner.java:370)
at org.apache.hadoop.mapred.YARNRunner.submitJob(YARNRunner.java:306)
at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:243)
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1290)
at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1287)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1595)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1287)
at org.apache.hadoop.tools.DistCp.createAndSubmitJob(DistCp.java:183)
at org.apache.hadoop.tools.DistCp.execute(DistCp.java:153)
at org.apache.hadoop.tools.DistCp.run(DistCp.java:126)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.tools.DistCp.main(DistCp.java:430)
what is this staging file and how do i get it? Is my syntax correct?
Running Capedwarf shows this error:
xybrek#ubuntu:~/CapeDwarf_WildFly_2.0.0.Final/bin$ ./capedwarf.sh /path/to/war
ls: cannot access './../modules/com/google/appengine/main/appengine-api-1.0-sdk-*-capedwarf*': No such file or directory
Exception in thread "main" org.jboss.modules.ModuleLoadException: Error loading module from /home/xybrek/CapeDwarf_WildFly_2.0.0.Final/modules/com/google/appengine/main/module.xml
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:155)
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:132)
at org.jboss.modules.LocalModuleFinder$1.run(LocalModuleFinder.java:154)
at org.jboss.modules.LocalModuleFinder$1.run(LocalModuleFinder.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.modules.LocalModuleFinder.findModule(LocalModuleFinder.java:148)
at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:455)
at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:358)
at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:305)
at org.jboss.modules.Module.addPaths(Module.java:1036)
at org.jboss.modules.Module.link(Module.java:1406)
at org.jboss.modules.Module.relinkIfNecessary(Module.java:1434)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:242)
at org.jboss.modules.Main.main(Main.java:385)
Caused by: org.jboss.modules.xml.XmlPullParserException: Failed to add resource root 'appengine-api-1.0-sdk-1.9.24-capedwarf.jar' at path 'appengine-api-1.0-sdk-1.9.24-capedwarf.jar' (position: END_TAG seen ...</filter>\n </resource-root>... #33:25) caused by: java.io.FileNotFoundException: /home/xybrek/CapeDwarf_WildFly_2.0.0.Final/modules/com/google/appengine/main/appengine-api-1.0-sdk-1.9.24-capedwarf.jar (No such file or directory)
at org.jboss.modules.ModuleXmlParser.parseResourceRoot(ModuleXmlParser.java:723)
at org.jboss.modules.ModuleXmlParser.parseResources(ModuleXmlParser.java:572)
at org.jboss.modules.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:394)
at org.jboss.modules.ModuleXmlParser.parseDocument(ModuleXmlParser.java:219)
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:153)
... 13 more
=========================================================================
What could be the fix for this? There's no such jar anywhere.
It looks like the bytecode modification didn't yet kick in.
(we modify GAE API jar on the fly the first time, as we need some bytecode hacks)
I'm trying to create a new JarFile using an existing File object but I keep getting a java.util.zip.ZipException: error in opening zip file.
I'm running the code below:
File x= new File("C:/Users/Priyanka/Documents/hello.java");
JarFile jarF = new JarFile(x);
when I run the code above I keep getting the error below:
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at prioritization.cfg.Test1.main(Test1.java:12)
I have tried this code on different machines and different version of eclipse but I keep getting the same issue.
I'm have tried to research the problem online but most of the solutions are about trying to open an existing .jar file.
Any help would be appreciated.
If you check the JavaDoc for the JarFile type, you'll see that it's only used for reading existing .jar files.
The JarFile class is used to read the contents of a jar file from any
file that can be opened with java.io.RandomAccessFile. - https://docs.oracle.com/javase/9/docs/api/java/util/jar/JarFile.html
To create a .jar file, you'll need to use a java.util.jar.JarOutputStream.
C:\phoneGap\firstApp>cordova run android
ANDROID_HOME=C:\Android\sdk\
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_74 Unzipping C:\Users\Somnath Sarkar\.gradle\wrapper\dists\gradle-2.13-all\7hsc6vr6mi3i6i5m7q9hj4ci1q\gradle-2.13-all.zip to C:\Users\Somnath Sarkar\.gradle\wrapper\dists\gradle-2.13-all\7hsc6vr6mi3i6i5m7q9hj4ci1qException in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.zip.ZipFile.<init>(ZipFile.java:163)
at org.gradle.wrapper.Install.unzip(Install.java:160)
at org.gradle.wrapper.Install.access$400(Install.java:29)
at org.gradle.wrapper.Install$1.call(Install.java:70)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) ... 3 more
Error: cmd: Command failed with exit code 1 Error output: Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.zip.ZipFile.<init>(ZipFile.java:163)
at org.gradle.wrapper.Install.unzip(Install.java:160)
at org.gradle.wrapper.Install.access$400(Install.java:29)
at org.gradle.wrapper.Install$1.call(Install.java:70)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) ... 3 more
Delete "gradle-2.13-all.zip" folder and everything in this directory:
C:\Users\Somnath
Sarkar.gradle\wrapper\dists\gradle-2.13all\7hsc6vr6mi3i6i5m7q9hj4ci1q\
Download the gradle zip manually click here
Paste the gradle zip folder in
C:\Users\Somnath
Sarkar.gradle\wrapper\dists\gradle-2.13-all\7hsc6vr6mi3i6i5m7q9hj4ci1q\
Run your
Codova build android
Caused by: java.util.zip.ZipException: error in opening zip file which means the concurrent ZIP file was Corrupted.
Solution :
Please Check the Zip file in C:\Users\YourUsername\.gradle\wrapper\dists\gradle-2.13-all\someRandomSting\ size and if it'size not equals to 66.6M then Download and Replace with this
The following was the error.
WARNING: Application name is not set. Call Builder#setApplicationName.
Exception in thread "main" java.io.FileNotFoundException: document.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at com.google.api.client.http.FileContent.getInputStream(FileContent.java:71)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:361)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:418)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at DriveCommandLine.main(DriveCommandLine.java:56)
Quickstart application uploads document.txt file from your local filesystem to Drive. Please place any file named document.txt on working directory of your application before executing the code.