[英]java.util.zip.ZipException: Not in GZIP format exception when launching java web start app with jnlp
我正在使用jnlp啟動Java Web Start應用程序。 jnlp是使用jsp動態生成的。 我在jnlp文件中將jnlp.packEnabled設置為true。 所有的罐子都用Java的pack200重新包裝,簽名和包裝。 使用以下螞蟻腳本。
<echo message="Repacking jars" />
<apply executable="pack200" parallel="false">
<arg value="--repack" />
<fileset dir="${build.dir}" includes="*.jar" />
</apply>
<echo message="Signing jars" />
<signjar destdir="${build.dir}" keyPass="test" keyStore="${project.root}/testKeys" storePass="test" alias="t">
<fileset dir="${build.dir}" includes="*.jar" />
</signjar>
<echo message="Pack Signed jars" />
<apply executable="pack200" parallel="false" dest="${build.dir}">
<arg value="--modification-time=latest"/>
<arg value="--deflate-hint=true"/>
<arg value="--segment-limit=-1"/>
<fileset dir="${build.dir}" includes="*.jar" />
<targetfile />
<srcfile />
<mapper type="glob" from="*" to="*.pack.gz" />
</apply>
java.util.zip.ZipException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(Unknown Source)
at java.util.zip.GZIPInputStream.<init>(Unknown Source)
at java.util.zip.GZIPInputStream.<init>(Unknown Source)
at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source)
at com.sun.deploy.cache.Cache.downloadResourceToTempFile(Unknown Source)
at com.sun.deploy.cache.Cache.downloadResourceToCache(Unknown Source)
at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
在網絡啟動應用程序上啟動其給與錯誤。 請提出如何解決此錯誤的建議。 當我嘗試用WINRAR查看* .pack.gz文件時,我只能看到一個擴展名為.pack的文件,我無法用WINRAR打開它說它是已損壞的文件。
編輯1 :文件未損壞。 我可以使用unpack200對其進行手動解壓縮,並從命令提示符下運行而沒有任何問題。 僅當從jnlp下載文件時才會顯示異常。 我懷疑從jsp動態生成jnlp會導致此問題。 下面是我的jsp代碼。 從動態生成的jnlp文件解壓縮時,請為我提供解決該異常的解決方案 。
<%@ page contentType="application/x-java-jnlp-file" language="java"%>
<%@page session="false" %>
<%
response.setContentType("application/x-java-jnlp-file");%>
<!-- JNLP File -->
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+">
<information>
<title>Service</title>
<vendor>Service</vendor> </information>
<security> <all-permissions /> </security>
<resources>
<jfx:javafx-runtime version="2.2.4+"
href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp" />
</resources>
<resources>
<!-- Application Resources -->
<property name="jnlp.packEnabled" value="true"/>
<j2se version="1.7+" />
<jar href="Test.jar" main="true"/>
</resources>
<application-desc
name="main" main-class="com.test.Main" width="300"
height="300">
<argument><%= request.getParameter("userId")%></argument>
<argument><%= request.getParameter("userName")%></argument>
</application-desc>
<update check="always" policy="always" />
</jnlp>
我建議您嘗試使用工具unpack200
(在JDK中)來查看您的.pack.gz是否正確。 如果沒有,則可能是硬件問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.