首页 文章

java.util.zip.ZipException:使用jnlp启动java web start app时,不会出现GZIP格式异常

提问于
浏览
0

我正在使用jnlp启动java web start应用程序 . jnlp是使用jsp动态生成的 . 我在jnlp文件中将jnlp.packEnabled设置为true . 所有的 jar 都用java的pack200重新包装,签名和包装 . 使用下面的ant脚本 .

<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打开它说这是一个损坏的文件 .

EDIT 1 :文件未损坏 . 我可以使用unpack200手动解压缩并从命令提示符运行,没有任何问题 . 仅当从jnlp下载文件时才会显示异常 . 我怀疑从jsp动态生成jnlp导致了这个问题 . 下面是我的jsp代码 . Could you please suggest me a solution to get rid of this exception when unpacking from dynamically generated jnlp file .

<%@ 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>

1 回答

  • 0

    我建议你尝试工具 unpack200 (它在JDK中),看你的.pack.gz是否正确 . 如果没有,则可能是硬件问题 .

相关问题