Uncaught exception w/ materials

Hello everyone. I am currently needing some help with this compiler error and right now im stumped. So i’m trying to make a class which contains all the scenery, like trees and plants, that way i can have all the code referring to leaves and stuff all in a seperate class away from main. Anyway, this scenery class is giving me some issues. It’s pretty much a normal class, doesnt extend simpleApplication and only has one method. This is the line where i try to create the material: Material leafMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

And here is my exception:

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


at com.jme3.material.Material.(Material.java:128)

at mygame.Scenery.trees(Scenery.java:34)

at mygame.Main.simpleInitApp(Main.java:87)

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

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)

iv’e spent ages trying to suss out whats going on, or find another way round but i just cant get my head round it.

here is Material.java, line 128: this((MaterialDef) contentMan.loadAsset(new AssetKey(defName)));


assetManager is null.

First, a “compile error” is an error that happens when you are compiling… ie: the compile fails.

This is a runtime error.

Second, we are not provided enough information to help further. Is it that your whole application doesn’t extend SimpleApplication or just the class that is trying to load the material? If it’s the first case then you are doing it wrong as your application should definitely be extending SimpleAppliction. If it’s the second case then you somehow need to give that class the assetManager and you haven’t.

1 Like

Ah, I see. I gave it assetManger and am no longer getting the error. Cheers!