NotOLE2FileException: Invalid header signature; read 0xE011BDBFEFBDBFEF, expected 0xE11AB1A1E011CFD0

I have just noticed that Maven is hellish in handling XLS files within resources. Am falling into:

Caused by: org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0xE011BDBFEFBDBFEF, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document

whole stack trace at:

http://pastebin.com/pZ1WZu4H

@mseaton: this happens when executing the Adult HIV Consultation Sheet report.

Setting maven filtering on src/main/resources within omod results into other issues since maven treats all the resources in there such as config in like manner.

Wondering why @mseaton/PIH may not have encountered this and if it did what was the way out!!!

Hi @k_joseph,

Picking this up on IRC, and just posting back from there for posterity so others can follow:

9:40:37 AM - mseaton: k-joseph: so first off, regarding the issue with “NotOLE2FileException: Invalid header signature”, are you seeing this on building with maven, or when running the report in the application?

9:41:07 AM - k-joseph: mseaton: when running the report in the application, building with maven is successfult

9:42:39 AM - mseaton: k-joseph: what omod is causing the problem? is this in rwandareports or did you copy this code out of there into a different module?

9:43:23 AM - k-joseph: mseaton: i moved it into a different module: GitHub - rwanda-rbc-emr/openmrs-module-rwandasphstudyreports

9:45:40 AM - mseaton: k-joseph: it is extremely likely that the issue is with resource filtering in maven, and you need to set up the pom correctly. one way you can test this is to build the module with maven, and then unzip the built omod and see if you can open the .xls resource or if it fails with an error. if it fails, you know the resource is corrupted during the build process.

9:48:57 AM - mseaton: k-joseph: see https://github.com/PIH/openmrs-module-rwandareports/blob/master/pom.xml line 183:215. this sets things up to only do resource filtering on xml and properties files, so that any other files within the resources (eg. binary excel files) are not mangled during the build

9:49:35 AM - mseaton: k-joseph: you’ll need to make sure you do this not only in the main pom, but also in the omod pom (or api pom) if the filtering is independently specified there.

Give this a try and let me know how things go.

Thanks, Mike

1 Like

Thanks @mseaton, setting maven filtering aright on api (where the .xls files/resources are) solves this issue. Setting filtering for the src/main/resources directory under build criteria as below solves this.

<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>false</filtering>
				<excludes>
					<exclude>**/*.xml</exclude>
					<exclude>**/*.properties</exclude>
				</excludes>
				<includes>
					<include>**/*.xls</include>
				</includes>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
				<includes>
					<include>**/*.xml</include>
					<include>**/*.properties</include>
				</includes>
			</resource>
		</resources>