SDK Terrain editor error handling when missing assets directory

I couldn’t find any game template in the SDK. Don’t know If I’ve broke it or if RC2-nightly doesn’t contain any right now. So I created an assets directory (no subdirectories), which the SDK didn’t recognize until I restarted it. Then I got the nice Assets-icon.

Then I created an empty scene and tried to add a new terrain spatial to the scene. Nothing happened after I finished the wizard. See below for the SDK log. So I tried again and the little red exception marker is visible in the SDK catching a NullPointer. I didn’t see it at first so perhaps there should be a little bit more prominent error-dialog, what do you think?


SEVERE [com.jme3.app.AppTask]: Exception
java.lang.NullPointerException
at javax.imageio.ImageIO.write(ImageIO.java:1538)
at com.jme3.gde.terraineditor.AddTerrainAction.doCreateTerrain(AddTerrainAction.java:135)
at com.jme3.gde.terraineditor.AddTerrainAction.generateTerrain(AddTerrainAction.java:100)
at com.jme3.gde.terraineditor.AddTerrainAction.doCreateSpatial(AddTerrainAction.java:69)
at com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialWizardAction$1$1.call(AbstractNewSpatialWizardAction.java:73)
at com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractNewSpatialWizardAction$1$1.call(AbstractNewSpatialWizardAction.java:70)
[catch] at com.jme3.app.AppTask.invoke(AppTask.java:142)
at com.jme3.app.Application.runQueuedTasks(Application.java:584)
at com.jme3.app.Application.update(Application.java:597)
at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:267)
at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:188)
at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:44)
at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:68)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:125)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:151)
at java.lang.Thread.run(Thread.java:722)
java.io.FileNotFoundException: /home/johan/projects/jme-testcases/CornerStablizationTest/assets/Textures/terrain-alpha/TerrainScene-terrain-TerrainScene-alphablend0.png (No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.(RandomAccessFile.java:233)
@jmaasing said:
I couldn't find any game template in the SDK.

Uh, something is quite wrong then.
It fails because it is looking for the Textures directory, and that isn't there. It creates the terrain-alpha directory in there. If the asset folders aren't there, then it might be difficult for many operation in jme, in particular the SDK, to perform.

So you don't see a BasicGame template in the New Project menu?
http://i.imgur.com/osO2n.png

Yes that’s the funny thing, I only see the JME3 Tests template. Must’ve broken my installation messing about with plugins :slight_smile:



Anyhow, I like to help so I was thinking that I could try to write a patch to make the error a bit more telling than an NPE. The catch-all red icon is a bit hard to see I think.

So I was wondering if there is some general strategy for error reporting. Like show a JME-branded dialog, or maybe that a plugin should try to correct the error before reporting. In this case try to create the missing texture directory.

I think it would improve the user experience of the SDK if there was some common feel to error reporting.

That the terrain editor expects the folder to be there and doesn’t create it is a bit beta-ish @Sploreg :wink:

@normen I agree and I have already made the change locally. However my point was that not seeing the basic game template is a bit concerning.

@Sploreg said:
@normen I agree and I have already made the change locally. However my point was that not seeing the basic game template is a bit concerning.

Oh yeah, defiitely, I also have no idea why thats the case. But actually there was no other error or so, this was the only exception.

Yeah I don’t know why just that template is missing, don’t recall messing with the provided templates. However I have been deleting some cache-directories and such while doing plugins so I need to verify my install first, might be just “user error” :slight_smile:

I installed the “Project Templates”-plugin from the update center and things are back to normal with the templates. Don’t know how I managed to remove that, didn’t even know it was a module. So yeah, “user error” :slight_smile:

Glad you got it working.

Some more noticeable errors might still be beneficial however. I think it might be possible to force netbeans to pop them up instead of hide them in the corner.

@Sploreg said:
Glad you got it working.
Some more noticeable errors might still be beneficial however. I think it might be possible to force netbeans to pop them up instead of hide them in the corner.

Yeah, I was looking into that. Seems no-one knows wtf you should use on the netbeans forums.

This is what is recommended in the Netbeans logging document.
[java] NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex);
DialogDisplayer.getDefault().notifyLater(e);[/java]

But that NotifyDescriptor.Exception is deprecated because it lead to race conditions. Which they solved by introducing notifyLater but forgot to de-deprecate the method a few years ago :(

Then some (IMO confused) decision was made to steal the logging framework output and if that indicated an exception it should be shown in the IDE, which is why you get the red icon for all sorts of exceptions, _even_ if you deal with them but want to log them anyway.

So this is what I'm doing, not perfect but better than nothing I guess.

[java]import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;

NotifyDescriptor notification =
new NotifyDescriptor.Message("An error message", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notifyLater(notification);[/java]

I read somewhere that you could use
org.openide.util .Exceptions#printStackTrace as a utility method, haven't tested that yet.
1 Like