Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in thread "main" java.util.zip.ZipException: Bad CRC checksum for entry META-INF/MANIFEST.MF #29

Closed
gregorkistler opened this issue Jul 30, 2022 · 10 comments

Comments

@gregorkistler
Copy link

Hi,

with the release of version 1.0.1 of the Tomcat Migration Tool for Jakarta EE I'm having some issues with a couple of jar files in my project which cannot be migrated due to an exception. Same jar(s) can be migrated using version 1.0.0:

jakartaee-migration-1.0.1-shaded.jar

$ java -jar jakartaee-migration-1.0.1-shaded.jar jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta 
Performing migration from source [/jna-platform-4.5.1.jar] to destination [/jna-platform-4.5.1.jar.jakarta] with Jakarta EE specification profile [TOMCAT]
Migration starting for archive [jna-platform-4.5.1.jar] using streaming
Exception in thread "main" java.util.zip.ZipException: Bad CRC checksum for entry META-INF/MANIFEST.MF: 16b8446c instead of 4535229
	at org.apache.tomcat.jakartaee.commons.compress.archivers.zip.ZipArchiveOutputStream.handleSizesAndCrc(ZipArchiveOutputStream.java:718)
	at org.apache.tomcat.jakartaee.commons.compress.archivers.zip.ZipArchiveOutputStream.closeArchiveEntry(ZipArchiveOutputStream.java:607)
	at org.apache.tomcat.jakartaee.Migration.migrateArchiveStreaming(Migration.java:228)
	at org.apache.tomcat.jakartaee.Migration.migrateStream(Migration.java:285)
	at org.apache.tomcat.jakartaee.Migration.migrateFile(Migration.java:197)
	at org.apache.tomcat.jakartaee.Migration.execute(Migration.java:163)
	at org.apache.tomcat.jakartaee.MigrationCLI.main(MigrationCLI.java:94)
	Suppressed: java.io.IOException: This archive contains unclosed entries.
		at org.apache.tomcat.jakartaee.commons.compress.archivers.zip.ZipArchiveOutputStream.finish(ZipArchiveOutputStream.java:534)
		at org.apache.tomcat.jakartaee.commons.compress.archivers.zip.ZipArchiveOutputStream.close(ZipArchiveOutputStream.java:1090)
		at org.apache.tomcat.jakartaee.Migration.migrateArchiveStreaming(Migration.java:214)
		... 4 more

jakartaee-migration-1.0.0-shaded.jar

$ java -jar jakartaee-migration-1.0.0-shaded.jar jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta 
Performing migration from source [/jna-platform-4.5.1.jar] to destination [/jna-platform-4.5.1.jar.jakarta] with Jakarta EE specification profile [TOMCAT]
Migration starting for archive [jna-platform-4.5.1.jar] using streaming
Migration finished for archive [jna-platform-4.5.1.jar]
Migration completed successfully in [529] milliseconds

Java version: OpenJDK 11 as well as OpenJDK 17
OS version: Ubuntu 22.04 as well as 20.04

Simple reproducer:

  1. fire up a OpenJDK Docker container, e.g. docker run -it --rm openjdk:11 bash
  2. download an affected jar like Java Native Access Platform 4.5.1
  3. download Tomcat Migration Tool for Jakarta EE 1.0.1
  4. try to migrate the jar, e.g. java -jar jakartaee-migration-1.0.1-shaded.jar jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta
@aooohan
Copy link
Member

aooohan commented Jul 31, 2022

You can do it like this: java -jar jakartaee-migration-1.0.1-shaded.jar -zipInMemory jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta

It's a little inefficient, but it'll work.

@gregorkistler
Copy link
Author

It's a little inefficient, but it'll work.

Thank you. Yes it works but as you've mentioned it's quite inefficient - takes ~150s instead of ~500ms for this specific jar and my project contains roughly 20 jar files 😅
I've meanwhile switched back to version 1.0.0 which works as intended.

@aooohan
Copy link
Member

aooohan commented Aug 1, 2022

I've meanwhile switched back to version 1.0.0 which works as intended.

Sure. The difference between 1.0.0 and 1.0.1 is that in order to solve #20, the logic was modified to use common-compression instead of JDK's zip implementation.

Hi,@gregorkistler.
I've tried to fix the problem, can you test it with this fixed version?
branch: https://github.com/aooohan/tomcat-jakartaee-migration/tree/test_deflated
OR
jar:
jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz

1.tar -zxvf jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz
2.cd jakartaee-migration-1.0.2-SNAPSHOT/lib
3.java -jar jakartaee-migration-1.0.2-SNAPSHOT.jar jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta

Note: This is not a release version, it has nothing to do with tc offical, it is only for testing.

Thanks

@gregorkistler
Copy link
Author

Hi,@gregorkistler. I've tried to fix the problem, can you test it with this fixed version? branch: https://github.com/aooohan/tomcat-jakartaee-migration/tree/test_deflated OR jar: jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz

1.tar -zxvf jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz 2.cd jakartaee-migration-1.0.2-SNAPSHOT/lib 3.java -jar jakartaee-migration-1.0.2-SNAPSHOT.jar jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta

Note: This is not a release version, it has nothing to do with tc offical, it is only for testing.

Thanks

LGTM

No exception any longer on any of the used jars. Thanks!

@aooohan
Copy link
Member

aooohan commented Aug 1, 2022

Hi,@gregorkistler. I've tried to fix the problem, can you test it with this fixed version? branch: https://github.com/aooohan/tomcat-jakartaee-migration/tree/test_deflated OR jar: jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz
1.tar -zxvf jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz 2.cd jakartaee-migration-1.0.2-SNAPSHOT/lib 3.java -jar jakartaee-migration-1.0.2-SNAPSHOT.jar jna-platform-4.5.1.jar jna-platform-4.5.1.jar.jakarta
Note: This is not a release version, it has nothing to do with tc offical, it is only for testing.
Thanks

LGTM

No exception any longer on any of the used jars. Thanks!

Thanks for the test. ;)

@nissan4x4
Copy link

Hi, @aooohan. I am experiencing the same issue as @gregorkistler with the CRC.

18-Aug-2022 14:55:06.339 WARNING [Catalina-utility-1] org.apache.catalina.startup.HostConfig.migrateLegacyApp Migration failure
	java.util.zip.ZipException: Bad CRC checksum for entry META-INF/MANIFEST.MF: 277a0274 instead of 5cfc51fe
		at org.apache.tomcat.jakartaee.commons.compress.archivers.zip.ZipArchiveOutputStream.handleSizesAndCrc(ZipArchiveOutputStream.java:718)

OS is Windows 2019 server
JAVA 8 (jre-8u341-windows-i586)
Tomcat 10.0.23

I'm having TC do the migration by placing the *.war into the webapps-javaee folder.

@aooohan
Copy link
Member

aooohan commented Aug 18, 2022

Hi, @nissan4x4
jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz

You can use this temporary tool to test whether the migration of your war package works.

  • tar -zxvf jakartaee-migration-1.0.2-SNAPSHOT-bin.tar.gz
  • cd jakartaee-migration-1.0.2-SNAPSHOT/lib
  • java -jar jakartaee-migration-1.0.2-SNAPSHOT.jar your-war.war target-your-war.war OR java -jar jakartaee-migration-1.0.2-SNAPSHOT.jar your-war-dir target-dir

Note: This is not a release version, it has nothing to do with tc offical, it is only for testing.

@nissan4x4
Copy link

nissan4x4 commented Aug 18, 2022 via email

@aooohan
Copy link
Member

aooohan commented Aug 18, 2022

but my OS is windows not Unix.

Sorry, I was careless.
jakartaee-migration-1.0.2-SNAPSHOT-bin.zip

The steps are the same, first you need to unzip the package, then go to the lib folder and execute the jakartaee-migration-1.0.2-SNAPSHOT.jar file(the command is the same).

JAVA_HOME/bin/java.exe -jar jakartaee-migration-1.0.2-SNAPSHOT.jar your-war.war target-your-war.war

@nissan4x4
Copy link

nissan4x4 commented Aug 18, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants