【问题标题】:Java Web Star java.lang.NullPointerException (JnlpxArgs.execProgram)Java Web Start java.lang.NullPointerException(Jnlp xArgs.exec 程序)
【发布时间】:2016-07-13 15:36:43
【问题描述】:

我有一个由 servlet 动态生成的 JNLP 文件。生成的 JNLP 为:

<jnlp spec="6.0+"  href="launch?param1=Hooolas">
      <information>
        <title>JSGD</title>
        <vendor>evconsul</vendor>
        <homepage href=""/>
        <description>JSGD</description>
        <description kind="short">JSGD</description>
        <offline-allowed/>
      </information>
      <update check="background"/>
      <security>
        <all-permissions/>
      </security>
      <resources>
        <j2se version="1.8+"/>
        <jar href="http://192.168.0.17:8080/Secu/huella/JSGD.jar" main="true"/>
      </resources>
      <application-desc main-class="jsgd.JSGD">
        <argument>Hooolas</argument>
      </application-desc>
    </jnlp>

客户端机器中的错误:

java.lang.NullPointerException
    at com.sun.javaws.JnlpxArgs.execProgram(Unknown Source)
    at com.sun.javaws.Launcher.relaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main.access$000(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Missing Application-Name manifest attribute for: http://192.168.0.17:8080/Secu/huella/JSGD.jar
#### Java Web Start Error:
#### null

我已经将所有库打包到一个名为 JSGD.jar 的 jar 中,它的结构是:

JSGD.jar
        -jsgd
        -META-INF
        -org
        -SecugenLib

我的jar的网址是:http://192.168.0.17:8080/Secu/huella/JSGD.jar

我已经通过 Netbeans 8.1 打包了我的应用程序 Files->/buil.xml 右键单击​​ Run Target->Other Targets->package-for-store。 这会在 Store 文件夹中生成一个 jar。这个 jar 具有上述结构。

在我的机器上运行正常(当代码库属性为:codebase="http://localhost:8080/Secu/" 当然!)。会有什么问题? JRE 版本 1.7.0_79-b15(客户端机器) 我使用 Netbeans 8.1

详情:

我已经覆盖了 build.xml 添加下一行;将所有类打包在一个 jar 中:

    <target name="package-for-store" depends="jar">  
         <!-- Cambien el valor de esta propiedad para dar el nombre al JAR,  
            sin la extensión .jar. No debe tener espacios.  
            <property name="store.jar.name" value="NombreDelJar"/>  
         -->  
         <property name="store.jar.name" value="JSGD"/>  
         <!-- No editar nada después de esta línea -->  
         <property name="store.dir" value="store"/>  
         <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>  
         <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>  
         <delete dir="${store.dir}"/>  
         <mkdir dir="${store.dir}"/>  
         <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">  
           <zipgroupfileset dir="dist" includes="*.jar"/>  
           <zipgroupfileset dir="dist/lib" includes="*.jar"/>  
 <manifest>  
         <attribute name="Main-Class" value="${main.class}"/>
         <attribute name="Application-Name" value="JSGD"/>
         <attribute name="Trusted-Only" value="true"/>
         <attribute name="Permissions" value="sandbox"/>
         <attribute name="Codebase" 
         value="http://192.168.0.17 http://localhost"/>
      </manifest>  
         </jar>  
         <zip destfile="${store.jar}">  
           <zipfileset src="${store.dir}/temp_final.jar"  
           excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>  
         </zip>  
         <delete file="${store.dir}/temp_final.jar"/>  
       </target>

更新

按照@mosquito-x 的建议,事情似乎变得更好了,但是 Java 7(我也在 jre-8u91 中尝试)阻止了它。 消息是:

 Application Blocked by Java Security.
    Name: JSGD
    From: http://192.168.0.17
    Reason: The Java Security Settings have this application from running. You may  change this behavior in Java Control Panel.

在 Java 控制面板站点列表中。我已经添加了这些网站:

http://192.168.0.17:8080
http://192.168.0.17:8080/Secu
http://192.168.0.17:8080/Secu/huella
http://192.168.0.17:8080/Secu/launch

提前致谢!

【问题讨论】:

  • 请务必使用 JaNeLA 检查 JNLP,可通过我的share drive 获取。
  • 嗨@AndrewThompson CVC - complex - type.2.4.a:从元素“security”中发现无效内容。他期望'{资源,应用程序 - desc,applet - desc 组件 - desc,-desc 安装程序}'之一。谢谢!
  • 这通常意味着 JNLP 中的某些元素的顺序错误。检查JNLP File Syntax 以找到正确的顺序。
  • @FernandoPie 你找到解决方案了吗?我面临同样的问题。

标签: java java-web-start jnlp


【解决方案1】:
  • JNLP:
    硬编码codebase="http://192.168.0.17:8080/Secu/"
    仅适用于本地主机

  • 导致java被阻塞

原因

java blocked

Java 进一步增强了安全性,使用户系统不易受到外部攻击。
从 Java 7 Update 51 开始,Java 不允许用户运行未签名(未签名)、自签名(未由受信任机构签名)或缺少权限属性的应用程序。 运行应用程序涉及的风险 未签名的应用程序

默认情况下会阻止没有证书的应用程序(即未签名的应用程序)或缺少应用程序名称和发布者信息。运行这种应用程序可能不安全并且存在更高级别的风险。 自签名应用程序(证书不是来自受信任的机构)

具有自签名证书的应用程序被阻止............

应用程序名称属性

Application-Name

Application-Name 属性在安全提示中用于为已签名的 RIA 提供标题。建议使用此属性来帮助用户做出信任和运行 RIA 的决定。该值可以是任何有效的字符串,例如:

应用程序名称:Hello World

如果 JAR 文件清单中不存在 Application-Name 属性............

修改清单文件

Modifying a Manifest File

在创建 JAR 文件期间,您可以使用 m 命令行选项将自定义信息添加到清单中。本节介绍 m 选项。

Jar 工具会自动将路径名为 META-INF/MANIFEST.MF 的默认清单放入您创建的任何 JAR 文件中。您可以通过修改默认清单来启用特殊的 JAR 文件功能,例如封装密封。通常,修改默认清单涉及向清单添加特殊用途的标头,以允许 JAR 文件执行特定的所需功能。

要修改清单,您必须首先准备一个文本文件,其中包含您希望添加到清单中的信息。然后,您使用 Jar 工具的 m 选项将文件中的信息添加到清单中。 警告:您从中创建清单的文本文件必须以换行符或回车符结尾。 如果最后一行没有以换行符或回车符结尾,则无法正确解析。

基本命令的格式如下:

jar cfm jar-file manifest-addition input-file(s)

让我们看看这个命令中使用的选项和参数:

The c option indicates that you want to create a JAR file.
The m option indicates that you want to merge information from an existing file ...
The f option indicates that you want the output to go to a file (the JAR file) ...
manifest-addition is the name (or path and name) of the existing text file ....
jar-file is the name that you want the resulting JAR file to have.
The input-file(s) argument is a space-separated list of one or more files ....

我的一个例子
清单.MF

Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.3 Main-Class: DataSummaryApplet Class-Path: lib/plugin.jar Application-Name: appJSN Trusted-Only: true Permissions: sandbox Created-By: 1.7.0_51-b13 (Oracle Corporation) Codebase: http://www.asitexx.com http://localhost

编辑:
1.) 大多数创建 jar 文件的 IDE 都使用 build.xml。 如果您更改项目中的某些内容,则此文件始终是新创建的。

你可以测试如果你改变:

<manifest>  
         <attribute name="Main-Class" value="${main.class}"/>  
</manifest>   

with(改变你的需要)

<manifest>  
         <attribute name="Main-Class" value="${main.class}"/>
         <attribute name="Application-Name" value="whatever"/>
         <attribute name="Trusted-Only" value="true"/>
         <attribute name="Permissions" value="sandbox"/>
         <attribute name="Codebase" value="http://www.asitexx.com http://localhost"/>
</manifest>  

您可以将域添加到代码库中,以空格分隔

2.) 从 JNLP 文件中删除不再需要的代码库

<jnlp spec="6.0+" codebase="http://192.168.0.17:8080/Secu/" href="launch?param1=Hooolas">

到

<jnlp spec="6.0+" href="launch?param1=Hooolas">

希望对你有帮助,
托马斯

更新 来自cmets

你认为我应该用证书签名??以及如何做到这一点?

这并不容易,您必须小心以正确的顺序执行所有操作。
小心:

仅使用纯 .jar 文件,其中包含所有库,甚至您自己创建的 MANIFEST.FM。

测试一下,打开的jar文件必须只包含libs以外的纯文本。 否 SHA-256-Digest 或7fnH8YhS5mkYtZoJqiWEI2bfSXSYd2alrKCEdvieyEk等其他部分。

然后你就可以继续接下来的步骤了。

许多链接中只有两个可能对您有所帮助。

To Generate a Certificate by Using keytool

Signing JAR Files

【讨论】:

  • 嗨@moskito-x 对不起,我已经生成了一个数据包.jar,其中包含运行我的应用程序所需的所有类。在这个 .jar 中有一个 META-INF>MANIFEST.MF。你是这个意思吗?它说:Manifest-Version: 1.0 Main-Class: jsgd.JSGD Name: SecuGen/FDxSDKPro/jni/SGDeviceList.class SHA-256-Digest: 7fnH8YhS5mkYtZoJqiWEI2bfSXSYd2alrKCEdvieyEk=(....)
  • 是的,我的意思是 META-INF/MANIFEST.MF 。必须有一行Application-Name: whatever!当然在你密封并签署罐子之前!
  • 好的。该行和其他行消失(在普通 jar 中有您在答案中描述的行)在新 jar(项目路径/存储)中,其中所有类只有两行:Manifest-Version:1.0 Main-Class:jsgd.JSGD更多的东西。我会尝试执行命令来覆盖它???在签署罐子之前。
  • 在本地机器 codebase=localhost:8080/Secu 运行,但我收到此警告我缺少应用程序名称清单属性:localhost:8080/Secu/huella/JSGD.jar 主 jar 中缺少权限清单属性:localhost:8080/Secu/huella/JSGD.jar
  • 您是否按照我的回答中所述设置了build.xml。只是重复Missing Application-Name 信息不多!!请编辑问题并添加您为创建包含Application-Name: 的 MANIFEST.MF 所做的步骤。
猜你喜欢
  • 1970-01-01
  • 2016-07-24
  • 2010-12-27
  • 2018-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-18
  • 1970-01-01
相关资源
最近更新 更多