Search code examples
javasecurityappletgluongluon-desktop

Exception at launching gluon application on Web Start


I am having the following exception when launching a Gluon application via webstart... i understand this is not GLUON particle directly related... it seems more a problem with the jar sign. The Exception:

java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at com.gluonhq.particle.application.Particle.<init>(Particle.java:170)
at com.gluonhq.particle.application.ParticleApplication.<init>(ParticleApplication.java:89)
at mx.gob.scjn.inventario.InventarioAJ.<init>(InventarioAJ.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Toolkit not initialized
    at com.sun.javafx.application.PlatformImpl.runLater(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.runLater(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(Unknown Source)
    at javafx.scene.control.Control.<clinit>(Unknown Source)
... 28 more

I already create my certificates using:

keytool -genkey -keyalg rsa -alias CLS -keystore mykeyStorte

then exporting it:

keytool -export -alias CLS -file rsatest.cer -keystore mykeyStore

I imported into the java control panel and sign the jar using:

jarsigner -keystore mykeyStore InventarioAJ.jar CLS

Obviously I am missing something... ¿Any clue? Greetings After getting the answer i got a "duplicate question" mark... but the right answer is not (as i thought) JUST the security/signing part... as a matter of fact the real and important part of the answer has to do with the fact that the Application class can not be cast as an applet and that requiers another change on the JNLP file.


Solution

  • That's right, Java 8 introduces some changes on JavaFX ( i really think this changes were in a later update, but that's not the point).. somehow today the JavaFX Application can't behave like an Applet, so the JNLP file has to look something like:

    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost/inventarioaj/" href="InventarioAJ.jnlp">
     <resources>
        <j2se version="1.8+" href=
           "http://java.sun.com/products/autodl/j2se"/>
        <jar href="/inventarioaj/InventarioAJ.jar" main="true" />
        <jar href="lib/controlsfx-8.40.10.jar"/>
        <jar href="lib/javax.inject-1.jar"/>
        <jar href="lib/particle-1.1.0.jar"/>
        <jar href="lib/h2-1.4.191.jar"/>
        <jar href="lib/eclipselink.jar"/>
        <jar href="lib/javax.persistence_2.1.0.v201304241213.jar"/>
        <jar href="lib/org.eclipse.persistence.jpa.modelgen_2.5.2.v20140319-9ad6abd.jar"/>
        <jar href="lib/org.eclipse.persistence.jpars_2.5.2.v20140319-9ad6abd.jar"/>
     </resources>
     <security>
        <all-permissions/>
     </security>
     <application-desc name="Inventario de XXXX"
     main-class="mx.xxxxx.InventarioAJ"/>
    

    So the "applet-desc" tag was removed and replaced by the "application-desc" tag and the "security" tag should be in place to allow the application to have access to the file system as well as the network communications. If that's the case (all permissions needed) then all jars must be signed. Greetings