I have an obfuscated jar created by proguard and with an application.properties file. If I try to recreate it with mavaen plugin, I got following error
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.15.BUILD-SNAPSHOT:repackage (default) on project project: invalid entry compressed size (expected 1052 but got 1053 bytes) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.15.BUILD-SNAPSHOT:repackage (default) on project project: invalid entry compressed size (expected 1052 but got 1053 bytes)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: invalid entry compressed size (expected 1052 but got 1053 bytes)
at org.springframework.boot.maven.RepackageMojo.repackage (RepackageMojo.java:220)
at org.springframework.boot.maven.RepackageMojo.execute (RepackageMojo.java:204)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.util.zip.ZipException: invalid entry compressed size (expected 1052 but got 1053 bytes)
at java.util.zip.ZipOutputStream.closeEntry (ZipOutputStream.java:267)
at org.springframework.boot.loader.tools.JarWriter.writeEntry (JarWriter.java:268)
at org.springframework.boot.loader.tools.JarWriter.writeEntries (JarWriter.java:146)
at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:281)
at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:262)
at org.springframework.boot.loader.tools.Repackager.repackage (Repackager.java:194)
at org.springframework.boot.maven.RepackageMojo.repackage (RepackageMojo.java:217)
at org.springframework.boot.maven.RepackageMojo.execute (RepackageMojo.java:204)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The problem occurs after update from Proguard 5.3.3 to 6.0.3 but Proguard should not be the problem because in source ja the file has correct size. The file size in source jar is compressed 1058 but if the maven plugin want to repacke this this will be 1057 in resulting jar. This stops the recreation.
I've tested the latest snapshot version due error 'https://github.com/spring-projects/spring-boot/issues/13525'
Comment From: wilkinsona
Thanks for trying a snapshot before opening this issue.
During repackaging, Spring Boot doesn't do anything with the size of compressed entries. It just reuses a JarEntry
from the source jar to write the entry into the repackaged jar. For zip files (typically jars in BOOT-INF/lib
) it may do a little more as they need to be stored rather than compressed in the fat jar. Looking at the error message it appears that a compressed entry is causing the problem in which case repackaging is simply using the size of the entry from the source jar.
The problem occurs after update from Proguard 5.3.3 to 6.0.3 but Proguard should not be the problem
From the information provided, it's not clear how you can discount Proguard from being the problem. It certainly appears to be involved, particularly as a version upgrade (with nothing else changing?) causes it to happen.
because in source jar the file has correct size.
How have you identified the file that's involved? That would be useful information to share.
Unfortunately, it's going to be very hard to diagnose this without a sample that reproduces the problem. From what I've seen thus far, it appears that the problem lies with the jar that's being passed into the repackaging and that is out of Boot's control.
Comment From: MCMicS
Hi thanks for answering. I'll try to create a simple sample for this on sunday. I've discount proguard because the output.jar looks fine with. The properties file in this jar has the size 1057 but after recreation call it stops with with an size of 1058 in Boot jar.
But like I said I create a sample on weekend.
Comment From: MCMicS
Sample: https://github.com/MCMicS/spring-boot-proguard
Following error is shown there:
Caused by: java.util.zip.ZipException: invalid entry compressed size (expected 571 but got 573 bytes)
The 'spring-proguard_proguard_base.jar' has the application.properties with 573 bytes and spring-proguard.jar.original 571
Comment From: wilkinsona
Thanks for the sample. I've reproduced the problem.
Comment From: MCMicS
Hi Andy, thanks for reproducing. Do you think its a spring or proguard error? My suspicion is that proguard uses an other compression for jar and then after copying the original files the sizes may be differ.
Comment From: wilkinsona
The problem's caused by Proguard 6 using a custom Deflater
with best compression and nowrap
set to true
. Repackaging currently assumes that the input jar file will have been written with the standard zip configuration. When this assumption does not hold true the output entry may have a different compressed size to the input entry which causes the failure seen here.
While Proguard's behaviour is unusual, it isn't, as far as I know, prohibited by the jar specification. We should update the repackager to cope with the compressed size changing.
Comment From: MCMicS
Hi Andy, thanks for finding out the problem. Maybe I found a way to use UncompressedZipEntryOutputStream instead of the compressed.
But a fix for non-default compression would be nice.
Comment From: MCMicS
Thanks for fixing so fast. With latest snapshot it works
Comment From: wilkinsona
Excellent. Thanks for trying a snapshot.
Comment From: cnzxc
how can I solve this problem? If I don't use the new version
Comment From: philwebb
@cnzxc Spring Boot 1.x is not supported anymore (see https://github.com/spring-projects/spring-boot/wiki/Supported-Versions#released-versions). Please upgrade.