2 Replies Latest reply: Nov 26, 2012 12:32 PM by 936814 RSS

    Problem running JavaFX application as web applet / web start

    936814
      Hi All,
      I need to run a JavaFX application as applet in a web page. To do that I use the html page
      generated by javafxpackager and all works fine if I launch the html page locally from my
      pc but when I load the html page from web server the application runs slow till freezing the browser.
      All jars are signed with a self-signed certificate, I've tried with Firefox, Chrome, IE and different servers.

      Same problem with web start (jnlp), locally works fine, launched from web it freezes.
      Enabling Java Console I've noticed a lot of log like:

      basic: JNLP2ClassLoader.findClass: java.lang.ImageView: try again ..
      basic: JNLP2ClassLoader.findClass: java.lang.ImageView: try again ..
      basic: JNLP2ClassLoader.findClass: java.lang.Image: try again ..
      basic: JNLP2ClassLoader.findClass: java.lang.Image: try again ..
      network: Cache entry not found [url: http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory, version: null]
      network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with proxy=DIRECT
      network: Connecting http://www.mysite.com:80/ with proxy=DIRECT
      network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with cookie "has_js=1"
      basic: JNLP2ClassLoader.findClass: java.lang.Font: try again ..
      basic: JNLP2ClassLoader.findClass: java.lang.Font: try again ..
      basic: JNLP2ClassLoader.findClass: javafx.scene.control.Font: try again ..
      basic: JNLP2ClassLoader.findClass: javafx.scene.control.Font: try again ..
      basic: JNLP2ClassLoader.findClass: javafx.scene.layout.Font: try again ..
      basic: JNLP2ClassLoader.findClass: javafx.scene.layout.Font: try again ..
      network: Cache entry not found [url: http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory, version: null]
      network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with proxy=DIRECT
      network: Connecting http://www.mysite.com:80/ with proxy=DIRECT
      network: Connecting http://www.mysite.com/applet/META-INF/services/javax.xml.stream.XMLInputFactory with cookie "has_js=1"

      What am I doing wrong?

      This is my jnlp (MyApp.jnlp)

      <?xml version="1.0" encoding="utf-8"?>
      <jnlp spec = "1.0" xmlns:jfx = "http://javafx.com" codebase = "http://www.mysite.com/applet/" href = "MyApp.jnlp">
      <information>
      <title>MyApp</title>
      <vendor>MyApp</vendor>
      <description>Sample JavaFX 2.0 application.</description>
      <homepage href = "http://www.mysite.com/applet/"/>
      <offline-allowed/>
      </information>
      <resources>
      <jfx:javafx-runtime version = "2.2+" href = "http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
      </resources>
      <resources>
      <j2se version = "1.6+" href = "http://java.sun.com/products/autodl/j2se"/>
      <jar href = "MyApp.jar" size = "2836601" download = "eager"/>
      <jar href = "libs/gson-2.2.2.jar" size = "189285" download = "eager"/>
      <jar href = "libs/sun.jar" size = "83743" download = "eager"/>
      </resources>
      <applet-desc width = "1280" height = "1024" main-class = "com.javafx.main.NoJavaFXFallback" name = "MyApp">
      <param name = "requiredFXVersion" value = "2.2+"/>
      </applet-desc>
      <jfx:javafx-desc width = "1280" height = "1024" main-class = "test.App" name = "MyApp"/>
      <update check = "background"/>
      </jnlp>

      and this my html page

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title>My App</title>
      <script src="http://java.com/js/dtjava.js"></script>
      <script>
      function launchApplication(jnlpfile) {
      dtjava.launch( {
      url : 'MyApp.jnlp'
      },
      {
      javafx : '2.2+'
      },
      {}
      );
      return false;
      }
      </script>

      <script>
      function javafxEmbed_fxApplication() {
      dtjava.embed(
      {
      id : 'fxApplication',
      url : 'MyApp.jnlp',
      placeholder : 'MyAppId',
      width : 1280,
      height : 1024
      },
      {
      javafx : '2.2+'
      },
      {}
      );
      }
      <!-- Embed FX application into web page once page is loaded -->
      dtjava.addOnloadCallback(javafxEmbed_fxApplication);
      </script>

      </head>
      <body>

                <div id="MyAppId"></div>

      </body>
      </html>

      Thank you
        • 1. Re: Problem running JavaFX application as web applet / web start
          936814
          Some more info,
          I watched the web server logs and I found many repeated log entries like
          "GET /applet/myapplet.html/META-INF/services/javax.xml.stream.XMLInputFactory HTTP/1.1" 404 19023 "-" "Mozilla/4.0 (Windows 7 6.1) Java/1.7.0_09"

          Googling this I've found many posts regarding similar problems:

          http://stackoverflow.com/questions/7997566/web-service-client-applet-keeps-asking-for-meta-inf-services-javax-xml-ws-sp

          http://stackoverflow.com/questions/2340969/applet-served-by-java-web-start-resources-requested-to-web-server-before-look-i

          It seems to be a strange Behaviour of the JNLPClassLoader that tries to load classes from server instead from jar or local class path.
          Somebody suggests to remove all logging entries from code or to add "codebase_lookup = false" to applet parameters but this does not solve the problem.

          I use FXML to define my UI and I think that every time an fxml is loaded JNLPClassLoader tries to load the xml parser (javax.xml.stream.XMLInputFactory)
          from server.

          Somebody have any idea?

          Thank you.
          • 2. Re: Problem running JavaFX application as web applet / web start
            936814
            Solved,
            see http://javafx-jira.kenai.com/browse/RT-25130