[SOLVED] Maven dependencies pulling incompatible version of nifty-default-controls

Hi guys,

I’m trying to construct a GUI with Nifty and have been following a few tutorials on how to do so (namely: http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:nifty_gui_java_layout which I found really useful).

I’m at the stage where I want to add a TextField - since I’m constructing my GUI in Java I’m using the TextFieldBuilder, but encounter a run-time warning, the result effect of which is that my TextField - although it renders - does not seem to respond to input:

WARNING: class [de.lessvoid.nifty.controls.textfield.controller.TextFieldControl] could not be instantiated (java.lang.ClassNotFoundException: de.lessvoid.nifty.controls.textfield.controller.TextFieldControl)

I looked into the dependency in question (nifty-default-controls) and it looks like the package structure changed in version 1.3:

de.lessvoid.nifty.controls.textfield.controller.TextFieldControl (pre v1.3)
de.lessvoid.nifty.controls.textfield.TextFieldControl (v.1.3+)

Now I’m using Maven to pull in all the revelant JME3 dependencies, the relevant section of my POM looks like this:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    
    <jme.version>3.0.10</jme.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.r2k</groupId>
        <artifactId>realms-of-kadia-transport</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>
    
    <dependency>
        <groupId>com.jme3</groupId>
        <artifactId>jme3-core</artifactId>
        <version>${jme.version}</version>
    </dependency>
    <dependency>
        <groupId>com.jme3</groupId>
        <artifactId>jme3-desktop</artifactId>
        <version>${jme.version}</version>
    </dependency>
    <dependency>
        <groupId>com.jme3</groupId>
        <artifactId>jme3-lwjgl</artifactId>
        <version>${jme.version}</version>
    </dependency>
    <dependency>
        <groupId>com.jme3</groupId>
        <artifactId>jme3-niftygui</artifactId>
        <version>${jme.version}</version>
    </dependency>

    <dependency>
        <groupId>org.bushe</groupId>
        <artifactId>eventbus</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>com.esotericsoftware</groupId>
        <artifactId>kryonet</artifactId>
        <version>2.22.0-RC1</version>
    </dependency>
    
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.1.3</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>jme3-repo</id>
        <url>http://updates.jmonkeyengine.org/maven/</url>
    </repository>
    <repository>
        <id>nifty-repo</id>
        <url>http://nifty-gui.sourceforge.net/nifty-maven-repo/</url>
    </repository>
</repositories>

It would seem that somewhere within the depths of one of these dependencies there is a reference to an older version of the nifty JAR than that which I am using (only version 1.3.3 gets inherited from the above dependencies).

I’ve tried manually excluding the v1.3.3 nifty dependencies and manually pulling down v1.2 but this breaks a large chunk of my code which evidently seems to be using some of the newer features (e.g.: nifty.loadStyleFile(“nifty-default-styles.xml”); is not valid in v1.2.

Does anybody have any experience with this or suggestions on how else I could circumvent the problem?

Many thanks in advance!

You don’t need the nifty repo, its all in the jme repo.

Sorry that was left in there from a previous attempt to fix the issue - the problem still persists if I remove it from the POM.

EDIT: Ahah! I think I’ve just sussed it. I’d copied a controlDefinition from somewhere and just pasted it without bothering to look at it - it would seem that’s what calling the class which no longer exists:

<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls>
  <controlDefinition style="nifty-textfield" name="textfield" controller="de.lessvoid.nifty.controls.textfield.TextFieldControl" inputMapping="de.lessvoid.nifty.controls.textfield.inputmapping.TextFieldInputMapping" passwordChar="$passwordChar" maxLength="$maxLength">
<panel id="textfield-panel" style="#panel" focusable="true">
  <interact onClick="onClick()" onClickMouseMove="onClickMouseMove()" />
  <panel id="textfield-field" style="#field" visibleToMouse="true">
    <text id="textfield-text" style="#text" text="$text" selectionColor="#000f"/>
  </panel>
  <panel id="textfield-cursor-panel" style="#cursor-panel">
    <image id="textfield-cursor" style="#cursor"/>
  </panel>
</panel>
</controlDefinition>
</nifty-controls>

I’ll just fix that to use the changed package and I should be all good - apologies for wasting your time, that will teach me to copy and paste.