3

I have some values that I need to appear in a MANIFEST.MF file to keep JAI happy with ImageIO.read.

Where do they need to exist to be available during the test phase of the maven cycle?

James Robinson
  • 1,222
  • 1
  • 15
  • 43

2 Answers2

2

Wouldn't that be in the test resources

src/test/resources/META-INF/MANIFEST.MF
Niels Bech Nielsen
  • 4,777
  • 1
  • 21
  • 44
  • I did try that but it didn't seem to pick them up. – James Robinson Apr 28 '14 at 17:19
  • The file will be copied, but if you want it put into a war or jar, you'll also need to ensure that the version from src/test/resources is what is used, rather than the version in src/main/resources. We'd need more info on how you're building your jar, to help you with that. – Paul Hicks May 04 '14 at 23:57
  • @PaulHicks the jar file is not his problem, he only wants the changed Manifest during test phase (i.e. before creation of the jars). – blackbuild May 05 '14 at 15:54
  • Yes, but it is possible that the problem is that the correct manifest is being ignored. We don't know exactly where he is looking for the manifest, or what part of his process is trying to use it. So another thing for him to investigate is probably a good idea. – Paul Hicks May 05 '14 at 19:02
  • As per below it seems the manifest.mf values are only available if you actually have a JAR – James Robinson May 10 '14 at 17:37
2

After an extensive search it seems this is impossible.

However, the issue should never arise because the JAI is inside a JAR and that JAR should contain the desired values. Consequently as suggested on a similar question I was indeed trying to compile the JAI. In my case because I am deploying one of my components as an executable to naive users I was using the shade plugin to build a "Fat JAR" which contained all the classes individually.

Unfortunately I have copied the pom.xml file that I had used to build this application into one of the class libraries that I reference and consequently this class library had become a "Fat JAR" too. This jar did not contain the values in the manifest even though it did reference the JAI libraries and consequently chaos ensued. The issue was compounded as that mistake was made many months ago and only now after an unrelated change had the version of JAI inside the particular Fat reference JAR come to be used by the JVM.

If you come across the same problem (as a search of the internet suggests others have) firstly try 2 things.

  1. Add the Specification-Vendor and Implementation-Vendor attributes to the manifest files of any jars you are building yourself.

  2. Build a simple application which just reads in any image file with ImageIO.read and then run this removing maven references one-by-one until the issue disappears and focus your efforts on this JAR.

James Robinson
  • 1,222
  • 1
  • 15
  • 43