Handling libraries: Help needed adding Nifty so you can browse source/debug

Hi all,



I’ve been running into some problems with Nifty and could really do with being able to step through and see exactly what’s going on in a few places. I also need to update with some enhancements/etc that have been done recently.



So my thought was to download and build my own Nifty and then swap it in for the one that comes with the SDK (I’m running latest Nightly).



So far I have:

  1. Install Maven Plugin
  2. Used Git to download nifty
  3. Used Maven to build the Nifty targets
  4. Added the Nifty Controls and Core project to SDK



    I then discovered that netbeans can’t add a reference to a maven project so I:
  5. Remove the Nightly nifty and nifty controls jar from the libraries list
  6. Add built target from inside the built maven project
  7. Edit the entry for that target in the libraries list, add the sources



    This seemed to work, the project built and I could [ctrl][shift]b on nifty and it took me to a valid Nifty.java with the source code.



    However I then tried to run the project and I got:

    SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

    java.lang.NoSuchMethodError: de.lessvoid.nifty.Nifty.(Lde/lessvoid/nifty/spi/render/RenderDevice;Lde/lessvoid/nifty/spi/sound/SoundDevice;Lde/lessvoid/nifty/spi/input/InputSystem;Lde/lessvoid/nifty/tools/TimeProvider;)V

    at com.jme3.niftygui.NiftyJmeDisplay.(NiftyJmeDisplay.java:105)

    at net.herodex.client.main.Main.simpleInitApp(Main.java:103)

    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:228)

    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)

    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

    at java.lang.Thread.run(Thread.java:722)



    The line in question is

    [java] nifty = new Nifty(renderDev, soundDev, inputSys, new TimeProvider());

    [/java]

    Which is correct and I can see the corresponding method in Nifty.java

    [java] public Nifty(

    final RenderDevice newRenderDevice,

    final SoundDevice newSoundDevice,

    final InputSystem newInputSystem,

    final TimeProvider newTimeProvider)[/java]



    What is odd though and might be a clue is that if I [ctrl][shift]b on the new Nifty line - I don’t get sent to a valid source file for Nifty.java. I end up at



    [java]public Nifty(RenderDevice newRenderDevice, SoundDevice newSoundDevice, InputSystem newInputSystem, TimeProvider newTimeProvider) {

    //compiled code

    throw new RuntimeException(“Compiled Code”);

    }

    [/java]



    So does anyone know what I’ve done wrong? I’ve checked that the Nifty snapshot jar has appeared in the libs folder, I’ve checked the library settings. I’ve tried cleaning and building and everything builds fine, etc. I did wonder if maybe I’ve accidentally deleted another library but the exception is clearly trying to load a method inside Nifty. It’s also a NoSuchMethodError not a ClassNotFoundException…







    When I get this working I’ll probably make a wiki page for it in case anyone else is trying to do similar.



    Thanks,

    Z

Just compile the jars somehow and make a new Library from them (Tools->Libraries), then add that to your project instead of the premade one, no need to replace them in the SDK build.

I just tried that and it made no difference, still get the exact same exception.

Well if you only use the “jme3” library then you import the nifty libs that come with the sdk, use the lwjgl-minimum and leave put the gui part. Described in the deployment / setup sections of the manual.

1 Like

I’ve read the deployment/setup sections and searched the documentation and haven’t seen anything describing how the libraries are set up or how to modify them. Do you have a link please?



Current setup:

Removed all JME etc libraries

Added my nifty-default-controls and NiftyCore (which is the library I created containing nifty + source).

Added lwjgl-minimum

Added jme3



I then had a compile error saying I was missing jme3.niftygui so I added the jar C:UsersTimAppDataRoaming.jmonkeyplatformnightlylibsjME3-niftygui.jar



I then got an error from nifty saying it needed event bus so I added the jar

C:UsersTimAppDataRoaming.jmonkeyplatformnightlylibseventbus.jar



And now I’m right back to where I was before:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NoSuchMethodError: de.lessvoid.nifty.Nifty.(Lde/lessvoid/nifty/spi/render/RenderDevice;Lde/lessvoid/nifty/spi/sound/SoundDevice;Lde/lessvoid/nifty/spi/input/InputSystem;Lde/lessvoid/nifty/tools/TimeProvider;)V

at com.jme3.niftygui.NiftyJmeDisplay.(NiftyJmeDisplay.java:105)

at net.herodex.client.main.Main.simpleInitApp(Main.java:103)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:228)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

at java.lang.Thread.run(Thread.java:722)

Hmm, I had this error as well before, with using an updated version of nifty (I’m using Eclipse though, so I don’t have the SDK library collections).

I’ll check if I can find what I did to fix it.



Edit: I can’t seem to reproduce the issue right now, trying different library versions.

The only difference I see between the versions is that the old nifty version accepts de.lessvoid.nifty.tools.TimeProvider while the new one accepts de.lessvoid.nifty.spi.time.TimeProvider.

The TimeProvider jME gives nifty is de.lessvoid.nifty.tools.TimeProvider, which extends de.lessvoid.nifty.spi.time.impl.AccurateTimeProvider, which in turn implements de.lessvoid.nifty.spi.time.TimeProvider.

Perhaps it’s because the new interface has the same name as the former class (a name space collision).

Giving it AccurateTimeProvider in NiftyJmeDisplay might work better with this new nifty version.

1 Like

Again, do not add the jme3 library. Am I talking to a tree?

https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:project_creation#adding_external_jar_libraries

https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:application_deployment#tipreduce_distribution_file_size

No need to be rude.



I’d already read both those. Neither seems helpful (edit to add: in this case).



When I added lwjgl-minimum only then I got build errors with all the core JME3 classes being missing. I then added the library called “jme3” which contains only “jme3-core.jar” and that fixed that error. I did not add jme3-libraries or any of the other ones except the lwjgl minimum.

@Tumaini said:
Hmm, I had this error as well before, with using an updated version of nifty.
I'll check if I can find what I did to fix it.

Edit: I can't seem to reproduce the issue right now, trying different library versions.
The only difference I see between the versions is that the old nifty version accepts de.lessvoid.nifty.tools.TimeProvider while the new one accepts de.lessvoid.nifty.spi.time.TimeProvider.
The TimeProvider jME gives nifty is de.lessvoid.nifty.tools.TimeProvider, which extends de.lessvoid.nifty.spi.time.impl.AccurateTimeProvider, which in turn implements de.lessvoid.nifty.spi.time.TimeProvider.
Perhaps it's because the new interface has the same name as the former class (a name space collision).
Giving it AccurateTimeProvider in NiftyJmeDisplay might work better with this new nifty version.


Thanks! That would certainly explain my symptoms. If jme3-nifty was built against a version of nifty that looks the same but in fact has a different type for TimeProvider then we would get exactly this error.

I guess the only way to fix it though would be to build jme3-nifty myself against the new nifty fixing the include to the correct type.

Gah this just keeps getting more complicated. All I wanted to do was step through a function and find out why the hell it isn't doing what I expected it to :(

Argh. This is really not my week. :?



Ok, followed the instructions here:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:build_jme3_sources_with_netbeans



First time SVN gave me an error “svn: Processing REPORT request response failed: XML document structures must start and end within the same entity” but google showed that as an intermittent problem with sorceforge svn so I cleaned the working copy and updated. This time it succeeded.



I then tried a clean and build as instructed and got

[java]init:

deps-clean:

Updating property file: C:ZS CurrentJME3buildbuilt-clean.properties

Deleting directory C:ZS CurrentJME3build

clean:

init:

deps-jar:

Created dir: C:ZS CurrentJME3build

Updating property file: C:ZS CurrentJME3buildbuilt-jar.properties

Created dir: C:ZS CurrentJME3buildclasses

Created dir: C:ZS CurrentJME3buildempty

Compiling 1039 source files to C:ZS CurrentJME3buildclasses

warning: [options] bootstrap class path not set in conjunction with -source 1.5

C:ZS CurrentJME3srcbulletcomjme3bulletPhysicsSpace.java:64: error: duplicate class: com.jme3.bullet.PhysicsSpace

public class PhysicsSpace {

C:ZS CurrentJME3srcbulletcomjme3bulletcollisionPhysicsCollisionEvent.java:44: error: duplicate class: com.jme3.bullet.collision.PhysicsCollisionEvent

public class PhysicsCollisionEvent extends EventObject {

C:ZS CurrentJME3srcbulletcomjme3bulletcollisionPhysicsCollisionEventFactory.java:40: error: duplicate class: com.jme3.bullet.collision.PhysicsCollisionEventFactory

public class PhysicsCollisionEventFactory {

C:ZS CurrentJME3srcbulletcomjme3bulletcollisionPhysicsCollisionObject.java:55: error: duplicate class: com.jme3.bullet.collision.PhysicsCollisionObject

public abstract class PhysicsCollisionObject implements Savable {

C:ZS CurrentJME3srcbulletcomjme3bulletcollisionPhysicsRayTestResult.java:42: error: duplicate class: com.jme3.bullet.collision.PhysicsRayTestResult

public class PhysicsRayTestResult {

C:ZS CurrentJME3srcbulletcomjme3bulletcollisionPhysicsSweepTestResult.java:40: error: duplicate class: com.jme3.bullet.collision.PhysicsSweepTestResult

public class PhysicsSweepTestResult {

[/java]



This is doing my head in :frowning: :cry:

Clearly the problem is that it’s trying to build multiple versions of bullet and noticing they are the same - which makes sense that it would fail - but presumably other people are able to build based on the wiki instructions and it works for them so what is different for me?



It all seems to be one project and there are no sub projects or build configurations that I can see so other than just deleting the duplicate bullets how is this supposed to work?

You are right, its the jme3-libraries I meant, sorry. Are you sure you have the newly checked out project as your main project? Else the button will build anything thats selected as the main project (so maybe some compile you tried to assemble yourself?) The project as it is in svn works fine, the build script compiles the bullet versions separately. No idea why you get such strange issues.

1 Like
@normen said:
You are right, its the jme3-libraries I meant, sorry. Are you sure you have the newly checked out project as your main project? Else the button will build anything thats selected as the main project (so maybe some compile you tried to assemble yourself?) The project as it is in svn works fine, the build script compiles the bullet versions separately. No idea why you get such strange issues.


The only conclusion I've come up with so far is that life hates me today.

Could version of netbeans make a difference? I'm trying to build with 7.0.1.

I'm right clicking on the jMonkeyEngine3 project and selecting clean and build directly from that. To be sure I just set it as main project and tried again with the same result. I'm going to leave it for tonight and take a fresh look tomorrow.

No idea… whats happening with command line ant? The project definitely works…

Just tried that actually, got exactly the same error. I also did svn clean and update from tortoise and it agrees with netbeans that everything is up to date.



Definitely gonna call it a night now though. Will look at it fresh in the morning and let you know how I get on.



Thanks for the help.

Progress!



Ok, This morning I fired up my backup dev machine and JME3 successfully downloaded and built on there.



With that as encouragement I wiped the download from yesterday and retried. This time everything downloaded without error and the project opened and built. So it seems the SVN error had corrupted something even though the cleanup and update claimed everything was fine.



Should I add a note to that effect to the relevant wiki or do you think this is rare enough that we can leave it?



(Incidentally build time on old machine 1min 37s - new machine 21s. I’m really liking the performance of my Raid 0 2*SSD system drive so far. Just to be cautious I make sure I keep subversion repositories on a different drive though so I always have backups!)

And it’s working, thanks for the help guys. I now have the latest version of nifty running and I can see source code, step through, debug, etc. :slight_smile:



Now back to solving the original problem!

And it turns out that if nifty calls a method in the screen controller and that method throws a null pointer exception the symptoms are identical to if the screen controller was never found at all…



Seems I had an error in one of the initialization paths and an internal variable wasn’t getting set up properly.



Argh.



Oh well, at least I’ve got nifty and JME3 all set up now. That’s something I’ve been wanting to sort out for a while.

I did encounter a similar problem this week. It seems netbeans/jMP’s cache sometimes get screwed up. Deleting the cache fixed the issue for me.



On Winblows:



Close jMP.

Delete the SDK’s cache found there → [drive]/user/“username”/AppData/roaming/.jmonkeyplatform/3.0beta/var/cache

Wait until files have been deleted then start jMP.



That fixed the problem for me.