1
votes

I'm trying to use Java Web Start to startup a java app from a local web page but getting security errors. Here is the jnlp file:

<jnlp spec="1.0+" 
      href="dynamictree_webstart_no_codebase.jnlp">
    <information>
        <title>Dynamic Tree Demo No Codebase</title>
        <vendor>Dynamic Team</vendor>
    </information>
    <resources>
        <!-- Application Resources -->
        <j2se version="1.7+"
              href="http://java.sun.com/products/autodl/j2se"/>
        <jar href="DynamicTreeDemo.jar" main="true" />
    </resources>
    <security>
        <all-permissions/>
    </security>    
    <application-desc
         name="Dynamic Tree Demo Application"
         main-class="webstartComponentArch.DynamicTreeApplication">
     </application-desc>
     <update check="background"/>
</jnlp>

If I use the following url:

file:///C:/Users/Greg/Desktop/JavaWebStartExamples/webstart_ComponentArch_DynamicTreeDemo/src/JavaWebStartAppPage_No_Codebase.html

Then I get a dialog with "Application Blocked by Java Security, Your security settings have blocked a local application from running"

So then I add "file://desktop-60nl2pl" to the Trusted Sites area in Chrome and uncheck "Require server verification (https:) for all sites in this zone" and change the url to the following:

"file://desktop-60nl2pl/Users/Greg/Desktop/JavaWebStartExamples/webstart_ComponentArch_DynamicTreeDemo/src/JavaWebStartAppPage_No_Codebase.html"

Then a dialog pops up saying "Unable to launch the application." Clicking the Details button reveals "java.lang.IllegalArgumentException: URI has an authority component at java.io.File.(Unknown Source) at com.sun.javaws.jnl.XMLFormat.setSourceURL(Unknown Source) ".

I've signed the jar with a self-signed crt but that apparently was not enough. I've read up on this problem and one possible solution seems to be that now it needs to be signed by a trusted CA cert. Really? Just for testing on my local computer? Surely there is another way?

EDIT1: Adding in the html code by request

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en-US">
  <head>
    <title>Dynamic Tree Java Web Start Application - Deployed Without Codebase</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  </head>
  <body>
    <h1>Dynamic Tree Java Web Start Application Demo - Deployed Without Codebase </h1>

    <script src="https://www.java.com/js/deployJava.js"></script>    

    <h2>Java Web Start application deployed by using the <code>launchWebStartApplication</code> function</h2>

    <p><a href="javascript:deployJava.launchWebStartApplication('dynamictree_webstart_no_codebase.jnlp');">Launch Dynamic Tree Demo application</a></p>

    <br/>
    <hr/>
    <br/>

    <h2>Java Web Start application deployed by using the <code>createWebStartLaunchButtonEx</code> function</h2>    

    <script>        
        var jnlpFile = "dynamictree_webstart_no_codebase.jnlp";
        deployJava.createWebStartLaunchButtonEx(jnlpFile);
    </script>
    <noscript>JavaScript is required for this page.</noscript>

  </body>
</html>

EDIT2: Here is the web page and Blocked Error screenshots: enter image description here enter image description here I click Open Java Web Launcher and then see this Blocked error: enter image description here

If I double click DynamicTreeDemo.jar, the app comes up ok. I just won't launch from the web page. enter image description here

2

2 Answers

0
votes

I have deployed a Java Swing application (packaged as an executable jar file) on a Apache Tomcat webserver and access the app using Java WebStart from a webpage; and here are some details. The JNLP file and the web page description respectively:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://www.thewebapp.com/"
        href="http://www.thewebapp.com/theapp-webstart.jnlp">
    <information>
        <title>The Application</title>
        <vendor>A Team</vendor>
    </information>
    <resources>
        <java version="1.7+"/>
        <jar href="theapp.jar" main="true" />
    </resources>
    <application-desc
        name="The Application"
        main-class="TheApp">
    </application-desc>
</jnlp>

The web page with the link to access the app:

<a href="theapp-webstart.jnlp">Click here to start the app</a>

The web page and the jnlp file are in the same folder (root) of the web app (its deployed as a WAR file) and on clicking the link on the webpage "Click here to start the app" the application starts on the client computer.

Also, in the Windows (7) control-panel -> Programs -> Java: this opens Java Control Panel. In the security-tab there is a check box "Enable Java content for browser and webstart applications" - check this.

0
votes

The solution was to add the following lines to the Exception Site List in the Java Control Panel,Security tab:

file:///C:/Users/Greg/Projects/Enventive/En360_UI/WebContent/DynamicTreeDemo.jar
file:///C:/Users/Greg/Projects/Enventive/En360_UI/WebContent/dynamictree_webstart_no_codebase.jnlp

Probably only need one of these two.