سؤال

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>
هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top