Packaging Fun

Thursday, March 4, 2010 by Matt Warman
You probably noticed that I haven't written anything lately. I was dealing with a head pounding issue with my JPA/JavaFX application (yes, it's still awesome!). When using NetBeans to create a JavaFX application, it creates JNLP files, a JavaFX JAR file, and a default HTML page to run in the browser.  This is a great way to run standalone or on a browser within NetBeans, but the packaging is not so great when you want deploy it to an application server like Glassfish. I had problems using the command line to WAR up those files, so I created a web application project, and moved the files mentioned above in the Web Pages directory. As any web application development guy will tell you, any libraries used should go in the WEB-INF/lib directory. Since I am using JPA (I put my entity and controller classes in a JAR), I added the JAR file and deployed..  no dice. The application deployed, and was trying to run (no 404s, etc.). The error message was that the JNLP file was throwing a null pointer exception. After checking for the proper JPA/JNLP/Server configurations online, everything was in order. Fun note: when looking for some JPA help, my own post showed up. I finally found the error message (pressing "5" in the Java console) and found that it wasn't loading the JPA classes! Wait it's in the proper directory! It works standalone! after some therapeutic primal screaming, I refocused and looked at the structure. The JavaFX files are in a Jar file, and the manifest file has the classpath for the JPA files. The JAR file is a part of a WAR file, so it's a zipped file inside of a zipped file. The fix is to add the "lib" directory of the JavaFX project (it is added to dist directory if you are using NetBeans) to same directory as the JavaFX JAR file. Your web application will not need the JPA files in the library.

Comments for Packaging Fun

Leave a comment





Captcha