use javafx app in web app etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
use javafx app in web app etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

6 Nisan 2011 Çarşamba

JavaFX MediaBox exception: Connection refused: connect.


Problem
When you build the JavaFX MediaBox component (or a modified version of it), Netbeans 6.9.1 ide produces the following files under dist folder.
MediaBox.html
MediaBox.jar
MediaBox.jar.pack.gz
MediaBox.jnlp
MediaBox_browser.jnlp

When you move those files to production environment (some other location or a web server), you may get the following error, when you try to see MediaBox.html via a browser.

exception: Connection refused: connect.
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
.....
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.net.ConnectException: Connection refused: connect

Solution
In my case, this was due to .jnlp files.
Editing codebase and homepage attributes accordingly in both MediaBox.jnlp and MediaBox_browser.jnlp files fixed the issue.


31 Mart 2011 Perşembe

revisited: using Java FX app in a web application

Please read for the background of this post: http://hilaltarakci.blogspot.com/2011/03/using-java-fx-app-in-web-application.html

Unfortunately, JavaFX MediaBox component did not run successfully, when i deployed the web application in production environment and test it from another client computer.
After a while, i realized that the problem is due to calling JavaFX from a .jsp file.. When JavaFX MediaBox is called from an .html file, no problem shows up..

28 Mart 2011 Pazartesi

using Java FX app in a web application

In order to pass media url as argument to Java FX MediaBox component,
  • change the Main.fxin MediaBox project as follows:
var mediaUrl = FX.getArgument("mediaUrl");

// in order to access mediaUrl, use mediaUrl.toString()
  • create a java web application project (i used Netbeans 6.5.1 for this).
  • edit index.jsp as follows:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script src="http://dl.javafx.com/dtfx.js"></script>
<script>
javafx(
{
archive: "MediaBox.jar",
width: 640,
height: 360,
code: "com.sun.javafx.mediabox.Main",
name: "MediaBox"
}, {
mediaUrl: "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_2956241001_big-buck-bunny-640x360.flv"
/*"file:/E:/htarakci/WORKSTATION/tez/projects/lost.avi"*/
}
);
</script>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
  • deploy the web app to server and run..

javafx samples here:

for deploying Javafx app:

for passing arguments to Javafx app:

a few tips on writing scripts: