Pack200 compression of jars issue with JRE bundle. - Advanced Installer Community
nanson
Posts: 5
Joined: Wed Sep 12, 2012 10:01 pm

Pack200 compression of jars issue with JRE bundle.

I've seen many topics about the Pack200 compression issue but I thought I would post a working example of this.

I am using Advanced Installer 9.9

The problem:
When using the Pack200 compression option with a java product, jar files are changed after decompression. One particular jar in the jre7u51 bundle (sunjce_provider.jar) was being broken to the point where the ability of our jsch jar to use the DH KeyPairGenerator was completely lost.

The solution:
Because we didn't want our exe to be 50% larger, we moved the sunjce_provider.jar to our system library folder (in Advanced Installer) and chose the Only from JRE bundle on the Pack200 compression option. Unfortunately we still increased the size of our exe by 30% b/c our system jar is no longer compressed.

I have an example project + resources example of this happening.

ZIP: https://www.dropbox.com/s/z84rxzj29p76c ... %20Bug.zip

You will notice that the size of sunjce_provider.jar changes from 194k to 190k after it is installed (jre7/lib/ext/sunjce_provider.jar is the before, Pack200Bug/jre/lib/ext/sunjce_provider.jar is the after).

This was a major thorn for us as compression was the last thing I would have suspected to be our problem. My development team tried many other solutions before finding this issue. Just simply breaking a jre bundle is pretty bad. I hope this gets addressed in the future. I didn't see any version change notes on this. Please correct me if it is fixed in a version later than 9.9.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Pack200 compression of jars issue with JRE bundle.

Hello,

The Pack200 compression IS NOT lossless, so may have be files with different sizes.

Please note that if you enable the Verify JAR files signature before and after packing option from the Java Settings when the Use Pack200 to compress the JAR files option is used then you can see in the build log:

The sunjce_provider.jar file signature has been broken by the packing process. This file will not be compressed with Pack200.

So, the files whose signature is broken will not be compressed with Pack200.

Please note that the Verify JAR signature option requires JDK installed on your development machine.

If there is anything else I can help with, please let me know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nanson
Posts: 5
Joined: Wed Sep 12, 2012 10:01 pm

Re: Pack200 compression of jars issue with JRE bundle.

Thank you for the reply. What you explained makes sense but I am not seeing the expected results.
I've installed JDK SE 7u51 on the deployment machine and checked the Verify JAR files signature before and after packing option in the Java settings.

After rebuilding (no cache), no such message came across the log:

Checking builds status... done.
Build required.
[ DefaultBuild ]
Building package (en): C:\Users\Nicholas\Desktop\Advanced Installer Bug\pack200bug.exe
Preparing files... done.
Creating LZMA archive... done.
Creating MSI database... done.
Writing Summary Information... done.
Compressing MSI database... done.
Creating EXE file... done.
Build time: 1 min 20 sec.

Total build time: 1 min 20 sec.
Build finished successfully.

I've looked in my C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext and verified that the size of sunjce_provider.jar is indeed 194k.

I again installed the .exe made from the new project with that option selected in the Java settings and still the jar is 190k.

Here is the new project, resources and installed results: https://www.dropbox.com/s/roqaqedqufie8 ... 20Bug2.zip

Am I missing something here? I even tried rebuilding without a cache after restarting my computer.

Still not working. Pulling jar out of the JRE and only compressing the JRE is our solution still. Any update as to why the jar is not getting skipped when using the verify option?
rossj
Posts: 16
Joined: Sun Jul 03, 2011 10:07 am

Re: Pack200 compression of jars issue with JRE bundle.

Hello,

Having just spent half a day debugging a problem, I have finally determined it to be the issue outlined in this post.
Pack200 is modifying both lib/jce.jar and lib/ext/sunjce_provider.jar, both of which fail to work after installation.
Given that JCE is such a fundamental component of the JRE, I am amazed this problem hasn't been fixed yet.

Has there been any progress made on this issue? I'm using AI 11.7.

/Ross
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Pack200 compression of jars issue with JRE bundle.

Hello Ross,

First of all I apologize for my delayed answer.

I'm not sure why this happens. I've tested the scenario, but I cannot replicate the behavior.

Can you consistently replicate the behavior? If so, it would be very useful if you could isolate the behavior in a buildable sample (aip + its referenced files) and send it us a download link to it so we can test and investigate on our side. If you don't have a web server where to host a sample which we can download, then just send us an e-mail to support at advancedinstaller dot com and we'll forward to you a FTP location.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rossj
Posts: 16
Joined: Sun Jul 03, 2011 10:07 am

Re: Pack200 compression of jars issue with JRE bundle.

Information sent as requested.
/Ross
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Pack200 compression of jars issue with JRE bundle.

Hello Ross,

Thank you for the sent sample. I've tested and replicated the behavior. This happens only when you don't have JDK installed on your build machine or when the JDK is installed, but its installation folder is not specified in our "File menu -> Options -> External Tools -> JDK folder" field. If the JDK installation folder is not specified in our "External Tools" settings, then even if you have enabled the "Verify JAR files signature before and after packing" option the JAR signature check won't be performed and the JAR files whose signature was broken will be included (with broken signature in the EXE setup). This is our default implementation. We'll update our "Java Settings" help page with this information in a future version of Advanced Installer, thank you for bringing this to our attention.

When a valid JDK installation folder is specified in our "External Tools" settings and the "Verify JAR files signature before and after packing" option is checked, then during the build operation you will be notified (in the build log) about the JAR files whose signature was broken.
screenshot.jpg
screenshot.jpg (115.4 KiB) Viewed 7001 times
Also, the above files won't be compressed with Pack200 and will be included in the setup as they are.

Therefore, can you please make sure you have specified a valid JDK installation folder in our "External Tools" settings, rebuild the project and test again the installation?

If you have any further questions just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rossj
Posts: 16
Joined: Sun Jul 03, 2011 10:07 am

Re: Pack200 compression of jars issue with JRE bundle.

Hello Daniel,

Thanks for your assistance and insight on this matter. I have done as you suggest and have confirmed that it does correct my problem. So thanks again for that.

In terms of how AI might be updated to avoid others encountering similar problems...

1. As you suggest, help on the Settings Tab should be updated (perhaps the existing note should be enhanced).
This is the most important change, as without it, a user probably wont make the connection that they need to update the External Tools for Pack200 to work correctly.

2. If the user selects 'Verify JAR file signatures before and after packing' but AI can't do that, surely a warning should be raised during the build?
This is the second most important change as not all users read the manual ;)

3. When I first looked at the External Tools > JDK option, it already refered to a JRE (C:\Program Files\Java\jre7\bin), which is clearly not a JDK and is thus inadequate.
I can only assume that AI somehow filled that in by default during installation. Curiously, I can't actually set this value now that I have something else, because AI does
verify whether it is a valid JDK, and it is not (it's a valid JRE bin directory).

4. The user guide help page for External Tools shows a screenshot of the options window with the value 'C:\Program Files\Java\jre6'. That's not valid either, and is misleading.

Cheers, Ross.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Pack200 compression of jars issue with JRE bundle.

Hello Ross,

You're always welcome. I'm glad you got this working.
1. As you suggest, help on the Settings Tab should be updated (perhaps the existing note should be enhanced).
This is the most important change, as without it, a user probably wont make the connection that they need to update the External Tools for Pack200 to work correctly.
The help was updated and it will be available starting with our next version of Advanced Installer.
2. If the user selects 'Verify JAR file signatures before and after packing' but AI can't do that, surely a warning should be raised during the build?
This is the second most important change as not all users read the manual ;)
This improvement was also added on our TODO list and hopefully it will be available soon.
3. When I first looked at the External Tools > JDK option, it already refered to a JRE (C:\Program Files\Java\jre7\bin), which is clearly not a JDK and is thus inadequate.
I can only assume that AI somehow filled that in by default during installation. Curiously, I can't actually set this value now that I have something else, because AI does
verify whether it is a valid JDK, and it is not (it's a valid JRE bin directory).
Indeed, if JRE is installed on the build machine Advanced Installer automatically detects it and set its installation folder in our "External Tools" settings. This is because, when no JDK is installed, AI uses JRE resources to compress JAR files within your installation project. However, if a JDK folder is specified in the "External Tools" settings, then it is not allowed to add a JRE fodler in our "JDK folder" field.
4. The user guide help page for External Tools shows a screenshot of the options window with the value 'C:\Program Files\Java\jre6'. That's not valid either, and is misleading.
Indeed, the "JDK folder" field has a bit improper name. We'll add an improvement in a future version of Advanced Installer to change its name into a more adequate one and also update the related screenshot. Thank you for bringing this to our attention too.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”