0

JavaFX 2.2 Developer preview (ビルド 19) の新しい「ネイティブ パッケージング」機能を使用しています。インストーラー (.exe) を正常にビルドできます。ただし、そのインストーラーを使用してデプロイされた JavaFX アプリケーションを開始すると、HTTPS 要求を行うたびに次の例外が発生します。

javax.net.ssl.SSLKeyException: RSA premaster secret error
    at sun.security.ssl.RSAClientKeyExchange.<init>(RSAClientKeyExchange.java:114)
...
Caused by: java.security.NoSuchAlgorithmException: SunTlsRsaPremasterSecret KeyGenerator not available
    at javax.crypto.KeyGenerator.<init>(KeyGenerator.java:158)
...

Eclipse からコードを開始するとき、またはアプリケーション フォームのコマンド ラインを開始するとき、すべてが正常に機能します。この問題は、インストーラーによって展開されたアプリケーションを起動したときにのみ発生します。

この例外を回避するにはどうすればよいですか?

問題を示すデモ コードをいくつか書きました。

Java FX アプリケーション:

package dk.bundleDemo;

import java.net.HttpURLConnection;
import java.net.URL;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import org.apache.log4j.Logger;

public class RunBundleTest extends Application {

    private static Logger log = Logger.getLogger(RunBundleTest.class);

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane root = new AnchorPane();
        Label statusLable = new Label();
        String statusText = "Status is: ";
        root.getChildren().add(statusLable);
        Scene scene = new Scene(root, 200, 200);
        primaryStage.setScene(scene);
        primaryStage.show();

        try {
            URL url = new URL("https://www.google.com");
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            Integer responseCode = conn.getResponseCode();
            statusLable.setText(statusText + responseCode.toString());
        }
        catch (Exception e) {
            log.error("error while connecting", e);
        }
    }

    public static void main(String[] args) {
        launch(args);
    }   
}

インストーラーを作成するための Ant スクリプト:

<project name="JavaFXSample" default="build and deploy" basedir="."
         xmlns:fx="javafx:com.sun.javafx.tools.ant">

    <target name="build and deploy">

        <property name="applet.width" value="500"/>
        <property name="applet.height" value="500"/>
        <property name="application.title" value="BundleTest"/>
        <property name="application.vendor" value="TestVendor"/>
        <property name="build.classes.dir" value=".\bin"/>
        <property name="basedir" value="."/>
        <property name="dist.dir" value="..\..\BundleTest"/>
        <property name="javafx.lib.ant-javafx.jar" value="C:\Program Files\Java\jdk1.7.0_06\lib\ant-javafx.jar"/>


        <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
                uri="javafx:com.sun.javafx.tools.ant"
                classpath="${javafx.lib.ant-javafx.jar}"/>

        <fx:application id="bundleTest"
                name="bundleTest"
                mainClass="dk.bundleDemo.RunBundleTest"
                />

        <fx:resources id="appRes">
            <fx:fileset dir="lib" includes="*.jar"/>
        </fx:resources> 

        <fx:jar destfile="lib\RunBundleTest.jar">
            <fx:application refid="bundleTest"/>

            <fx:resources refid="appRes"/>

            <manifest>
                <attribute name="Implementation-Vendor"
                        value="${application.vendor}"/>
                <attribute name="Implementation-Title"
                        value="${application.title}"/>
                <attribute name="Implementation-Version" value="1.0"/>
            </manifest>

            <fileset dir="${build.classes.dir}"/>
        </fx:jar>


        <fx:deploy width="${applet.width}" height="${applet.height}"
                outdir="${basedir}/${dist.dir}" embedJNLP="true"
                outfile="${application.title}"
                nativeBundles="all"
                >

            <fx:application refId="bundleTest"/>

            <fx:resources refid="appRes"/>            

            <fx:info title="${application.title}"
                    vendor="${application.vendor}"/>

        </fx:deploy>

</target>
</project>

JavaFX ネイティブ パッケージングの詳細: https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx

4

1 に答える 1

3

問題は JavaFX 2.2 Developer preview のバグです: http://javafx-jira.kenai.com/browse/RT-23889

于 2012-08-15T07:46:24.903 に答える