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.


4 Nisan 2011 Pazartesi

problem passing time info through jaxws web service

reading http://hilaltarakci.blogspot.com/2009/10/revisited-troobleshooting-date-becomes.html beforehand may be useful for this post..


there was a problem while passing date info through jaxws web service; time info was absent..
However, editing the DateAdapter as follows solved the problem:

public class DateAdapter {

public static Date parseDate(String s) {
System.out.println("========= DateAdapter.parseDate param:" + s);
System.out.println("========= DateAdapter.parseDate:" + DatatypeConverter.parseDate(s).getTime().toString());
return DatatypeConverter.parseDate(s).getTime();
}

public static String printDate(Date dt) {
Calendar cal = new GregorianCalendar();
cal.setTime(dt);
//System.out.println("========= DateAdapter.printDate param:" + dt.toString());
System.out.println("========= DateAdapter.printDate: " + DatatypeConverter.printDateTime(cal).toString());
return DatatypeConverter.printDateTime(cal).toString();
}
}