3
votes

It is years since I have worked in Java (that's my excuse).

I am trying to launch a Java Swing UI as an Applet (previously done via Web Start).

I have modified the jnlp file to reflect the changes that I know are necessary for an applet (e.g. using applet-desc instead of application-desc).

Inside the <resources> tag in the jnlp file we set system properties like this:

<property name="java.security.auth.login.config" value="$$context/app/auth.conf"/>

In the init method of the main class we try to read some of these system properties and always get "null" as the value.

  1. Does anyone have any ideas why the system properties aren't "sticking"?

  2. Possibly related strangeness: I have Java set to open the console when something runs. When I load the page with this applet, the console windows opens TWICE, both windows showing the details of loading the jnlp, but only one window continues with the full app load.

UPDATE:

Here is the jnlp file:

 <?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" >
  <information>
    <title>app</title>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <resources>
      <j2se version="1.6+" java-vm-args="-Xms128m -Xmx1024m -Xss1m"/>
      <property name="java.naming.factory.initial" value="org.jboss.naming.HttpNamingContextFactory"/>
      <property name="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
      <property name="java.naming.provider.url" value="$$context/invoker/JNDIFactory"/>
      <property name="java.security.policy" value="$$context/app/server.policy"/>
      <property name="java.security.auth.login.config" value="$$context/app/auth.conf"/>
      <property name="login.context" value="client-login"/>
      <property name="jndi.port" value="1099"/>
      <property name="service.impl" value="Remote"/>
      <property name="polling" value="true"/>
      <jar href="cglib-2.1.3.jar"/>
      <jar href="com.jdas.apps.binmgmt.gui.jar" main="true"/>
      <jar href="commons-beanutils.jar"/>
      <jar href="commons-collections-2.1.1.jar"/>
      <jar href="commons-javaflow.jar"/>
      <jar href="commons-lang.jar"/>
      <jar href="commons-logging.jar"/>
      <jar href="ecs-1.4.1.jar"/>
      <jar href="hibernate3.jar"/>
      <jar href="itext-1.01.jar"/>
      <jar href="jade-5.2.3_AGRIS_PATCH.jar"/>
      <jar href="jbossall-client.jar"/>
      <jar href="jboss-j2ee.jar"/>
      <jar href="jcalendar-1.1.4-agris.jar"/>
      <jar href="jhall-3.1.3.jar"/>
      <jar href="looks-all-1.1.jar"/>
      <jar href="odmg-3.0.jar"/>
      <jar href="pvjdbc2.jar"/>
      <jar href="swing-layout-1.0.jar"/>
      <extension name="additional" href="unsigned.jnlp"/>
  </resources>
  <applet-desc main-class="com.jdas.apps.binmgmt.gui.main.BinManagementApp" name="binMgmt" width="1024" height="768" >

  </applet-desc>
</jnlp>
2
What is the entire JNLP file (as it arrives at the client)? Has it been validated (I recommend JaNeLA)? Was the 'Java Swing UI' originally based on a JFrame, JApplet..? - Andrew Thompson
@Andrew Thompson: jnlp added to the question. I have validated via JaNeLA which complains that there was invalid content starting with element 'jar' -- which I don't understand, seems to match my understanding of a valid jnlp file. The Swing UI main class was originally a class that launched JFrames. I made the class extend JApplet - Steve
Did you check the JaNeLA help page? To wit: "This one fools a lot of people. It most often means that elements are out of the correct order in the launch file. Check the spelling, then try shifting the element further up the document." Affirmative on the conversion, though I am wondering what possesses people to take a free floating GUI and cram it into a web page. - Andrew Thompson
@Andrew Thompson: thank you for the JaNeLA help...my jnlp no longer has errors. We have a customer requiring that we run the Swing app inside a browser for apparently valid reasons. - Steve

2 Answers

4
votes

You will need to sign the JNLP file in order to set system properties (other than those properties that have special exemption). Look at some of those properties you are trying to set!

To sign a JNLP file, put a byte-for-byte copy (best to stick to US-ASCII(!)) in JNLP-INF/APPLICATION.JNLP before signing the jar.

2
votes

Just spent 2 days trying to fix this problem, trying to sign jars and other files...and then I found the solution which seems to be very simple and is working fine:

I *put a jndi.properties-file with the following content in my JRE-home-director*y (jre7/lib):

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099

I had this problem when updating from Java 1.6 to Java 1.7...