Deploying JavaFX on Glassfish and Facebook

Thursday, January 21, 2010 by Matt Warman

First, sorry for the tardiness of my posts. Between the holidays, coming back from the holidays, a cold, and a secret project (for now), I haven't had time to blog.. until now. My current focus has been a Facebook game application. Well it's still in the alpha phase, but I wanted to get the architecture up and running. There's nothing worse for an application development person than to finish your application, then find out you need to rewrite it (or worse) because of the architecture doesn't support it. Even without Zembly, setting up a Facebook application is pretty easy. Since I had most of the defaults already in, the only thing I need to do is to tell Facebook where my application resides. Since I don't have Zembly anymore, I have to put on my application development and network administrator hats on set up an application server.
My first test was to deploy the application into my local Tomcat. NetBeans does a great job of having the files available to you, but the thing you learn quickly is that there isn't a simple deployment piece. Tomcat needs a WAR file, so I tried to use the JAR command to WAR up the files in the dist folder. No dice. The war file needs a proper web.xml file to work properly. Rather than use workarounds on workarounds, I created a web application project in NetBeans, linked the jar file from my JavaFX project, and copied the JNLP and HTML files to my new project. I now have a WAR to deploy. Tomcat loves this file. I run and... “FILE NOT FOUND?” was heard all throughout Cincinnati. Your JNLP file that was created points to a servlet called internally by NetBeans. Make sure change the following lines:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://your server.com/app path/" href="SBWarsTest_browser.jnlp">
<information>
<title>SBWarsTest</title>
<vendor>STAR BASE </vendor>
<homepage href="http://your server.com/app path/"/>

Once I made the change to localhost, everything was fine. Now I wanted a real application server, so I downloaded and installed Glassfish V.2.1 on one of our servers, changed the JNLP file and we are in business. I tried to hit it from my machine, and no dice. After some extensive research, I found out the the Java 7 EA JRE does not play well with JavaFX. I uninstalled it (which reverted to JRE 1.6.18), and it works. In Facebook, you need to set the canvas callback URL to your host application path. The result is the pretty picture you see at the top of my post.

Comments for Deploying JavaFX on Glassfish and Facebook

Saturday, March 27, 2010 by Randin:
Have you thought about revisiting this topic? You and one other blog talk about this subject and he deploys with PHP so yours is the only purely Java example. Maybe extend it by making a sample app and going through it, even giving the code out for people to inspect. Just a thought.
Monday, April 19, 2010 by Matt Warman:
Currently, I have used just the defaults to put it on Facebook. There are Java APIs that could allow you to make this a pure Java solution, but I haven't tried them yet. THe problem is that Facebook is not Java friendly when it comes to deployment. That might change if there is a big push to use Java applets, and specifically JavaFX.

Leave a comment





Captcha