Java Web Star java.lang.NullPointerException(JnlpxArgs.execProgram) [英] Java Web Star java.lang.NullPointerException (JnlpxArgs.execProgram)

查看:113
本文介绍了Java Web Star java.lang.NullPointerException(JnlpxArgs.execProgram)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由servlet动态生成的JNLP文件.生成的JNLP是:

I have a JNLP file which is generated by a servlet dynamically . The JNLP generated is:

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

客户端计算机中的错误:

The error in a client machine:

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中,其结构为:

I have packed all libraries in one jar called JSGD.jar its struct is:

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

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

The URL of my jar is: 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具有上述结构.

I have packed my app via on Netbeans 8.1 Files->/buil.xml right click Run Target->Other Targets->package-for-store. This generates a jar inside in Store folder. This jar has the struct described above.

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

In my machine runs ok(when codebase attribute is: codebase="http://localhost:8080/Secu/" of course! ). What would be the problem? JRE version 1.7.0_79-b15(Client Machine) I use Netbeans 8.1

详细信息:

我覆盖了build.xml,并添加了以下几行;将所有类打包到一个jar中:

I have overwritten build.xml adding the next lines; to pack all classes in one 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中尝试过)将其阻止. 消息是:

Following the advices from @mosquito-x, seems the thing goes better, but Java 7(I'm trying in jre-8u91 too) block it. The message is:

 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控制面板的站点"列表中.我添加了以下网站:

In Java control panel Site list. I have added these sites:

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

提前谢谢!

推荐答案

  • JNLP:
    硬编码的codebase="http://192.168.0.17:8080/Secu/"
    仅适用于本地主机

    • The JNLP :
      a hardcoded codebase="http://192.168.0.17:8080/Secu/"
      will only work on localhost

      导致Java被阻止

      原因

      Java被阻止

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

      Java has further enhanced security to make the user system less vulnerable to external exploits.
      Starting with Java 7 Update 51, Java does not allow users to run applications that are not signed (unsigned), self-signed (not signed by trusted authority) or that are missing permission attributes. Risks involved in running applications Unsigned application

      默认情况下,没有证书的应用程序(即未签名的应用程序)或缺少应用程序名称和发布者信息的应用程序将被阻止.运行此类应用程序可能不安全,并且风险更高. 自签名应用程序(证书不是来自受信任的机构)

      An application without a certificate (i.e. unsigned apps), or missing application Name and Publisher information are blocked by default. Running this kind of application is potentially unsafe and present higher level of risk. Self-signed application (Certificate not from trusted authority)

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

      An application with self-signed certificate is blocked ............

      应用程序名称

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

      The Application-Name attribute is used in security prompts to provide a title for your signed RIA. Use of this attribute is recommended to help users make the decision to trust and run the RIA. The value can be any valid string, for example:

      应用程序名称:Hello World

      Application-Name: Hello World

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

      If the Application-Name attribute is not present in the JAR file manifest ............

      修改清单文件

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

      You use the m command-line option to add custom information to the manifest during creation of a JAR file. This section describes the m option.

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

      The Jar tool automatically puts a default manifest with the pathname META-INF/MANIFEST.MF into any JAR file you create. You can enable special JAR file functionality, such as package sealing, by modifying the default manifest. Typically, modifying the default manifest involves adding special-purpose headers to the manifest that allow the JAR file to perform a particular desired function.

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

      To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest. Warning: The text file from which you are creating the manifest must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.

      基本命令具有以下格式:

      The basic command has this format:

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

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

      Let's look at the options and arguments used in this command:

      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 ....
      

      我的例子之一
      MANIFEST.MF

      example one of mine
      MANIFEST.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

      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. 如果您在项目中进行更改,此文件总是新创建的.


      1.) Most IDE's who creates the jar file, uses a build.xml. The bad thing this file is always new created if you change something in the project.

      您可以测试是否进行了更改:

      You can test if you change :

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

      具有(根据您的需求更改)

      with (change to your needs)

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

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

      you can add domains to the codebase seperated by a blank

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

      2.) Remove the code base from JNLP file it's not needed anymore

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

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

      希望有帮助,
      托马斯

      Hope it helps,
      Thomas

      更新 从评论中

      您认为我应该使用证书签名??以及如何做到?

      You think that I should sign with a certificate?? and How do that?

      那不是那么容易,您必须小心以正确的顺序进行所有操作.
      注意:

      that is not that easy and you have to be careful to do everything in the correct sequence.
      Be careful:

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

      Only pure .jar file use, that has all libs and even your self created MANIFEST.FM in it.

      对此进行测试,打开的jar文件必须仅包含libs纯文本除外. SHA-256-Digest或其他部分,例如7fnH8YhS5mkYtZoJqiWEI2bfSXSYd2alrKCEdvieyEk等.

      Test this, open the jar file must contain only except the libs plain text. No SHA-256-Digest or other parts like 7fnH8YhS5mkYtZoJqiWEI2bfSXSYd2alrKCEdvieyEketc.

      然后您可以继续进行下一步.

      Then you can with the next steps proceed.

      只有两个链接可能会对您有所帮助.

      only two links of many that may help you.

      使用密钥工具生成证书

      签名JAR文件

      这篇关于Java Web Star java.lang.NullPointerException(JnlpxArgs.execProgram)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆