1

I'm trying to package my application as a Web Start usign the ZenJava plugin for Maven.

mvn -pl XXX com.zenjava:javafx-maven-plugin:web -DskipTests -DmainClass=XXX.Main -Dproject.organization.name=XXX -DkeystoreAlias=selfsigned -DkeyStorePassword=XXX -DallPermissions=true -DkeyStore=./keystore.jks

This produces the following artifacts:

/lib
XXX-jfx.jar
XXX.html
XXX.jnlp

If I start my application from the jar, everything works as expected, but if I start the jnlp I get a NPE regarding the Location like the one in this topic.

What I'm using to read the required resource is

Thread.currentThread().getContextClassLoader().getResource("relative/path/from/package/root")

Tried all different ways to load it described in the linked topic without success. What am I missing? Doesn't the working jar mean my class loading is correct? Here's the important part of the JNLP as well.

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="XXX-0.0.1.jnlp">
  <information>
    <title>Sample JavaFX Application</title>
    <vendor>XXX</vendor>
    <description>Sample JavaFX 2.0 application.</description>
    <offline-allowed/>
  </information>
  <resources>
    <jfx:javafx-runtime version="8.0+" 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="xxx-jfx.jar" size="44875" download="eager" />
    <!-- Bunch of other jars here -->
  </resources>
  <applet-desc  width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback"  name="XXX-0.0.1" >
    <param name="requiredFXVersion" value="8.0+"/>
  </applet-desc>
  <jfx:javafx-desc  width="800" height="600" main-class="XXX.Main"  name="XXX-0.0.1" />
  <update check="background"/>
</jnlp>

Let me know if you need more information.

Thanks in advance.

Community
  • 1
  • 1
Mooncrosser
  • 139
  • 1
  • 2
  • 9
  • Have you tried using an absolute path specific to your classpath? – ItachiUchiha May 01 '15 at 13:34
  • Isn't this the same as the one I'm using (relative from package root)? – Mooncrosser May 01 '15 at 14:51
  • Be sure to check the JNLP using JaNeLA, available at my [share drive](https://drive.google.com/drive/#folders/0B5B9wDXIGw9lUnJaUjA2cmlVRE0). BTW - I'm pretty sure it won't pick up the problem of having two identically targeted `resource` elements. Fix that besides any other problems reported. – Andrew Thompson May 02 '15 at 03:54
  • @AndrewThompson I run JaNeLa and there were only 2 red errors reported that likely were risen because JaNeLa requires Java 7 to run and I've analyzed Java 8 JNLP: `cvc-complex-type.2.4.a: Invalid content was found starting with element 'jfx:javafx-runtime'. One of '{java, j2se, jar, nativelib, extension, property, package}' is expected. cvc-complex-type.2.4.d: Invalid content was found starting with element 'jfx:javafx-desc'. No child element is expected at this point.` – Mooncrosser May 02 '15 at 10:11
  • @AndrewThompson I've also merged the resources elements. Issue still persists. To make it clear, the resource I'm trying to get is located in application jar in a folder Y/Z and I'm referring to it as: `Thread.currentThread().getContextClassLoader().getResource("Y/Z/main.fxml")` – Mooncrosser May 02 '15 at 10:11
  • It will work under Java 8 just as well as Java 7 (Java is upwards compatible!). The problem is that the DTD I used to develop the XSD that checks the JNLP does not account for Java-FX. If you can find a DTD for a Java-FX based JNLP, I might update it. `"Y/Z/main.fxml"` In what package it the class that calls that? If it were `"/Y/Z/main.fxml"` it would not matter, but the way it is written, it does. – Andrew Thompson May 02 '15 at 10:30
  • @Andrew Thompson It's in the same package – Mooncrosser May 04 '15 at 08:23
  • *"It's in the same package"* Then the String should be either a relative URL `"./main.fxml"` or `"main.fxml"` or an absolute URL from the root of the class path `"/Y/Z/main.fxml"` (note **leading `/`**). I'm surprised you have not tried it yet! – Andrew Thompson May 04 '15 at 08:31
  • @Andrew Thompson The thing is, I did try them out, I even setup a testing code just now for the sake of the argument, here's the result: `main.fxml did not work! ./main.fxml did not work! X/Y/main.fxml did not work! /X/Y/main.fxml did not work!` PS. I'm using Thread.currentThread().getContextClassLoader().getResource() method. – Mooncrosser May 06 '15 at 12:59
  • I've updated to JDK 1.8.45 and now I'm hitting something that looks like [this bug](https://bugs.openjdk.java.net/browse/JDK-8051030?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel). Screw it, I'll do without jnlp. – Mooncrosser May 06 '15 at 14:06

0 Answers0