0

I am trying to generate a native image of a JavaFX+FXML application using the GluonHQ client-maven-plugin. Creating the native image works fine, but when trying to execute it, it seems my configuration was wrong.

FXML

<?import java.lang.*?>

<?import org.prelle.javafx.NavigationView?>
<?import org.prelle.javafx.NavigationItem?>
<?import org.prelle.javafx.NavigationItemHeader?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.layout.FlowPane?>

<NavigationView xmlns:fx="http://javafx.com/fxml"
    stylesheets="@styles.css"
    displayMode="AUTO">
</NavigationView>

The execution fails with org.apache.logging.log4j.message.ParameterizedMessageFactory ClassNotFoundException: org.prelle.javafx.NavigationView

Now I tried to add my reflectionconfig.json

[
  {
    "name" : "org.prelle.javafx.NavigationView",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true
  }
]

The problem now is that it doesn't compile annymore. Instead I get 3 errors for classses that have been unintentionally initialized at build time - e.g. javafx.scene.control.SkinBase or the skin for my class org.prelle.javafx.skin.NavigationViewSkin

My NavigationView constructor explicitly sets the skin to NavigationViewSkin, so calling the empty constructor will call the skins constructor as well.

What did I do wrong? How can I avoid those errors?

Edit: I failed to notice that I copied an older error message (from having problems with Log4J2). Changed it.

taranion
  • 631
  • 1
  • 6
  • 17
  • Can you try without FXML first? FXML uses reflection, and forces adding all the required classes to the reflectionconfig.json file. Without FXML, it should be easier to test your project with the Client plugin. Once it fully works, you can try FXML. Typically, skins are not required in the reflection file. – José Pereda Aug 22 '20 at 19:24
  • Without FXML the problem isn't unintentionally initialization at build time anymore - just a ClassNotFoundExcpetion for org.prelle.javafx.skin.NavigationViewSkin. I am not sure why though. The skin is explicitly imported from the component, so the dependency existed. I will test around. To be clear: I don't consider this a problem of the client-maven-plugin - at best I missed a way to configure it properly. I just wanted to make sure I did not miss anything important. – taranion Aug 23 '20 at 14:43
  • Add that class to the `reflectionList` in the plugin or to the json file, seems to be used reflectively. – José Pereda Aug 23 '20 at 14:47

0 Answers0