Bug 64086 - No valid entries or contents found, this is not a valid OOXML.
Summary: No valid entries or contents found, this is not a valid OOXML.
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.2-FINAL
Hardware: PC Linux
: P1 blocker (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-19 05:23 UTC by Kanish Jain
Modified: 2021-01-13 07:24 UTC (History)
2 users (show)



Attachments
file which is working in windows but not in linux (82 bytes, text/plain)
2020-01-19 05:48 UTC, Kanish Jain
Details
Here is the snapshot of java code which i am using to read the excel file. (88.52 KB, image/png)
2020-01-19 05:54 UTC, Kanish Jain
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kanish Jain 2020-01-19 05:23:54 UTC
Hi Team,
       While I am trying to read the attached excel file from windows java program using Apache POI 4.1.0. It is working file, I am able to get the data But when I am trying to read the same excel from ubuntu and same java program using same Apache POI 4.1.0. It is throwing the following error.

"org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException: No valid entries or contents found, this is not a valid OOXML (Office Open XML) file
	at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.getNextEntry(ZipArchiveThresholdInputStream.java:144)
	at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:49)
	at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:106)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:301)
	at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:37)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:303)
	at com.valforma.projectag.helper.ExcelFTPHandler.readFile(ExcelFTPHandler.java:95)
	at com.valforma.projectag.helper.BatchfileStepProcessor.processStep(BatchfileStepProcessor.java:140)
	at com.valforma.projectag.helper.StepHelper.processStep(StepHelper.java:20)
	at com.valforma.projectag.service.GenericCron.processStep(GenericCron.java:270)
	at com.valforma.projectag.service.GenericCron.processJobDetails(GenericCron.java:176)
	at com.valforma.projectag.service.GenericCron$$FastClassBySpringCGLIB$$edb293f8.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
	at com.valforma.projectag.service.GenericCron$$EnhancerBySpringCGLIB$$735039d6.processJobDetails(<generated>)
	at com.valforma.projectag.rest.JobInvoker.invoke(JobInvoker.java:94)
	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)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.valforma.projectag.config.SimpleCorsFilter.doFilter(SimpleCorsFilter.java:38)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.zip.ZipException: Unexpected record signature: 0X1404034B
	at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:260)
	at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.getNextEntry(ZipArchiveThresholdInputStream.java:140)
	... 113 more
" 

Please help me to fix the same.
Comment 1 Kanish Jain 2020-01-19 05:48:30 UTC
Created attachment 36971 [details]
file which is working in windows but not in linux
Comment 2 Kanish Jain 2020-01-19 05:54:18 UTC
Created attachment 36972 [details]
Here is the snapshot of java code which i am using to read the excel file.
Comment 3 Andreas Beeker 2020-01-19 21:06:27 UTC
I've downloaded your file from google drive and it works on my side, i.e. on Ubuntu.
As a side note - although the data looks unsuspicious, I guess this is a SAP table extract ... which I wouldn't provide for every one ...

To triage the problem, I would temporarily save the downloaded file (from the FTP server) to disc, to rule out any transfer errors.

From the stacktrace I don't see, if the archive is corrupted from the beginning (e.g. because you receive an error instead of the file) or was truncated in between.
Comment 4 Dominik Stadler 2020-02-02 09:38:23 UTC
Bug was opened "P1"/"Blocker", but no response for 2 weeks, so closing this for now as we do not see a problem with the actual file here, please re-open with the requested information if necessary.
Comment 5 Kais hamdulay 2021-01-10 12:36:10 UTC
Hi i am facing same issue.
The xlsx works fine on windows but fails in linux with same error
Comment 6 Kais hamdulay 2021-01-12 11:00:44 UTC
Hi I am facing a similar issue faced by kanish
the file works smoothly on windows but when I transfer file in binary mode using winscp to the ftp server and read it from the i get the below error 

org.apache.poi.openxml4j.exceptions.InvalidOperationException: Could not open the specified zip entry source stream
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:212)
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:194)
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:168)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:149)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:277)
at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:124)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:327)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:295)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:276)
at com.shari.importer.helper.ImportCommonHelper.initializeFile(ImportCommonHelper.java:434)
at com.shari.importer.helper.ImportCommonHelper.getMappedStock(ImportCommonHelper.java:291)
at com.shari.importer.processor.XLSXMerchantImportSetupProcessor.remoteFetchAndProcess(XLSXMerchantImportSetupProcessor.java:136)
at com.shari.importer.processor.XLSXMerchantImportSetupProcessor.processMerchantImportSetups(XLSXMerchantImportSetupProcessor.java:102)
at com.shari.importer.processor.XLSXMerchantImportSetupProcessor.process(XLSXMerchantImportSetupProcessor.java:71)
at com.shari.importer.service.MerchantCatalogImportService.importMerchantsCatalog(MerchantCatalogImportService.java:40)
at com.shari.importer.consumer.AutomatedMerchantCatalogImportEventConsumer.consumeEvent(AutomatedMerchantCatalogImportEventConsumer.java:24)
at com.broadleafcommerce.jobsevents.service.DatabaseSystemEventNodeImpl.executeEvent(DatabaseSystemEventNodeImpl.java:827)
at com.broadleafcommerce.jobsevents.service.DatabaseSystemEventNodeImpl$5$1.execute(DatabaseSystemEventNodeImpl.java:756)
at com.broadleafcommerce.jobsevents.service.consumer.EventLockUtil.runLockedOperation(EventLockUtil.java:139)
at com.broadleafcommerce.jobsevents.service.DatabaseSystemEventNodeImpl$5.run(DatabaseSystemEventNodeImpl.java:749)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.EOFException: unexpected EOF - expected len: 1848089 - actual len: 1847932
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:196)
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:149)
at org.apache.poi.openxml4j.util.ZipArchiveFakeEntry.<init>(ZipArchiveFakeEntry.java:47)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:53)
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:210)
... 22 common frames omitted



2021-01-12 13:52:03.868 ERROR 8070 --- [QueueStatusThreadPoolTaskExecutor-1] c.s.i.p.XLSXMerchantImportSetupProcessor : Error Occurred processing XLSX merchant import for : price change - {​​ c1af6f9d-cc62-4695-bee9-624fb037b36b}​​
Comment 7 Andreas Beeker 2021-01-12 12:17:22 UTC
> unexpected EOF - expected len: 1848089 - actual len: 1847932

please verify the file on Windows/Linux is the same, e.g. by using "md5 <file>".
I'm quite sure it's truncated ...
Comment 8 Kais hamdulay 2021-01-12 12:36:42 UTC
Hi andreas,
There is one difference here I am reading the file from FTPClient and then downloading it on the linux server.
I am apache FTPClient to read the file in binary mode and then write it to linux server and then read it from there
However,all these operations work fine if the server i it is on windows
But throws the error on linux.

I can verify the length using the command
Comment 9 Kais hamdulay 2021-01-13 06:28:30 UTC
Hi I checked the md5 and its coming different for the file on windows and the other one that i had copied using winscp to the ftp server and later on read the file from ftp using FTPClient and written that file on linux server local path from where i am reading it.
I have checked from the code perspective its  perfect as i am setting the file type as binary while reading the file from ftp and writing the bytes to destination file using below code.
Howevr,I am not sure what is going wrong here


 for (FTPFile ftpFile : result) {
                boolean canDownload = this.isFileEligibleForDownload(merchantImportSetup, ftpFile);
                if (ftpFile.isFile() && canDownload) {
                    ftpFile.setType(FTPSClient.BINARY_FILE_TYPE);
                    log.info("Save the file to db");
                    log.info("file to be read from ftp location is : " + ftpFile.getName());
                    String remoteFile = "/" + merchantImportSetup.getDirectory() + "/" + ftpFile.getName();
                    File localPath = new File(fileSystemBaseDirectory + File.separator + merchantCatalogImporterFileService.getRandomizedFile(ftpFile.getName()));
                    OutputStream outputStream2 = new BufferedOutputStream(new FileOutputStream(localPath));
                    InputStream inputStream = ftpClient.retrieveFileStream(remoteFile);
                    byte[] bytesArray = new byte[4096];
                    int bytesRead = -1;
                    while ((bytesRead = inputStream.read(bytesArray)) != -1) {
                        outputStream2.write(bytesArray, 0, bytesRead);
                    }
                    boolean success = ftpClient.completePendingCommand();
                    if (success) {
                        System.out.println("File #2 has been downloaded successfully.");
                    }
                    outputStream2.close();
                    inputStream.close();  

}
Comment 10 Kais hamdulay 2021-01-13 07:24:16 UTC
I have found the solution for the issue,.
The issue was with the reading of file from ftp client
Below settings are recommended to avoid falling into this issue from FTPClient

Before every file read or write we need to set the             ftpClient.setFileType(FTP.BINARY_FILE_TYPE) which is very important and solved my issue

  ftpClient = getFTPClient();
            ftpClient.setConnectTimeout(connectionTimeout);
            ftpClient.connect(url, port);
            ftpClient.enterLocalPassiveMode();
            ftpClient.setControlEncoding("UTF-8");
            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);

            //login
            if (!ftpClient.login(ftpAuth[0], ftpAuth[1])) {
                ftpClient.logout();
            }

  for (FTPFile ftpFile : result) {
                boolean canDownload = this.isFileEligibleForDownload(merchantImportSetup, ftpFile);
                if (ftpFile.isFile() && canDownload) {
                    log.info("Save the file to db");
                    log.info("file to be read from ftp location is : " + ftpFile.getName());
                    String remoteFile = "/" + merchantImportSetup.getDirectory() + "/" + ftpFile.getName();
                    File localPath = new File(fileSystemBaseDirectory + File.separator + merchantCatalogImporterFileService.getRandomizedFile(ftpFile.getName()));
                    OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(localPath));
                    ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
                    ftpClient.retrieveFile(remoteFile, outputStream);
                    //since file is already copied into local file system , upload it to OSS
                    log.info(merchantImportSetup.getFriendlyImportName() + "-" + "file is downloaded from FTP at " + localPath.getAbsolutePath());
                    String ossPath = merchantCatalogImporterFileService.uploadToOSS(merchantImportSetup, localPath);
                    log.info(merchantImportSetup.getFriendlyImportName() + "-" + "file is uploaded to OSS at " + ossPath);
                    downloadFile = localPath;
                    IOUtils.closeQuietly(outputStream);
                    break;
                }
            }