Java.lang.IllegalArgumentException: MALFORMED


(Ildar Gilfanov) #1

Gradle gradle-2.11(12). Сan not deploy WAR, built on the OS Windows 8.1 on a Apache-tomcat-8.0.27 running OS Centos.

Maybe should not be used archivers OS Windows 8.1.

java.lang.IllegalArgumentException: MALFORMED
at java.util.zip.ZipCoder.toString(ZipCoder.java:58)
at java.util.zip.ZipCoder.toStringUTF8(ZipCoder.java:117)
at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:297)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121)
at sun.tools.jar.Main.extract(Main.java:875)
at sun.tools.jar.Main.run(Main.java:263)
at sun.tools.jar.Main.main(Main.java:1177)


(Lance Java) #2

I’m guessing that one of your paths / filenames contains special characters. It’s likely you’ll need to set the encoding property to UTF-8 so that filenames are encoded correctly. Eg:

war {
   encoding = 'UTF-8'
}

(Ildar Gilfanov) #3

did not help:

compileJava.options.encoding = ‘UTF-8’

tasks.withType(JavaCompile) {
options.encoding = ‘UTF-8’
}


(Lance Java) #4

Please re-read my answer. It’s not the compile task’s encoding, it’s the war/zip task’s encoding


(Ildar Gilfanov) #5

I it to that it really help? Thank you. I’ll try


(Lance Java) #6

Highly possible since the error is occuring at ZipInputStream.getNextEntry


(Ildar Gilfanov) #7

Strangely, under OS Debian 8, the WAR is deployed successfully, without any add-ons


(Ildar Gilfanov) #8

WAR is deployed successfully,Thank you ! All the same, it would be desirable that there was auto-detect the correct encoding.


(Lance Java) #9

Are you expecting this to be implemented in Gradle? Sounds like a Tomcat feature request to me

The zip format is a bit of a mess in that there’s no standard for filename encoding. If you want a war/zip that is guaranteed to work across platforms, you must avoid non-ASCII characters in filenames (more info here)