AssetLoadException suddenly happening after update


I’ve recently started playing with jmonkey as an alternative to processing/flash. I must say that I’m impressed by the quality of this project. But yesterday I encountered an unexpected issue. Here is the error I get:

com.jme3.asset.AssetLoadException: An exception has occured while loading asset: Materials/TestMat1.j3m
at com.jme3.asset.DesktopAssetManager.loadAsset(
at com.jme3.asset.DesktopAssetManager.loadAsset(
at com.idflood.svj.objects.CircleGeom.(CircleGeom.scala:117)

So, the code was working nicely, I updated jmonkey, tried again and got these error. The previous version was maybe 2 weeks older. While trying to find the cause of the issue I've found that this seems to only happen when it tries to "custom" material. I can easily recreate the materials if needed since the project contains only 3 of them (all really basic, one unshaded, one with lightning, on with lightning and wire).
So how can I fix this? Or how can i debug this effectively (tried to put some breakpoints but this didn't helped me that much)?
I don't think this is really relevant, but here is some code(written in scala):

//this line pass without error
val mat_s = new Material(Main.getAssetManager, "Common/MatDefs/Misc/Unshaded.j3md")
// the following line raise the exception
val mat = Main.getAssetManager.loadAsset("Materials/TestMat1.j3m").asInstanceOf[Material]

And for the curious, here is a video showing the experiment in it's last working state (nothing changed since, appart from the jmonkey update):

edit: I tried to create a new material from scratch an load it instead. Still the same error. I also noticed that in jmonkeyplatform material editor the preview isn't working anymore (on top left).

Was there a root cause for the exception?

It coming from this line:

val mat = Main.getAssetManager.loadAsset(“Materials/TestMat1.j3m”).asInstanceOf[Material]

Which is the line 117 of CircleGeom.scala as beeing reported by the error. So, if I understand correctly the material file is found but there is a problem while loading it.

edit: the part throwing the error from DesktopAssetManager (line 242)

AssetInfo info = handler.tryLocate(key);
if (info == null){
throw new AssetNotFoundException(key.toString());
try {
o = loader.load(info);
} catch (IOException ex) {
throw new AssetLoadException("An exception has occured while loading asset: " + key, ex); // <- the exception comes from there

edit2: here are the source of one of those material, nothing fancy:

Material My Material : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
Diffuse : 0.8 0.0 0.2 1.0
Shininess : 13.0
AdditionalRenderState {

Yes, and you see how this passed the original exeption:

throw new AssetLoadException(“An exception has occured while loading asset: ” + key, ex); // ← the exception comes from there

It was probably in the stack trace from which you pasted but maybe you truncated it before the really important part. It’s not the AssetLoadException that is important in this case but the cause of it.

ok, thanks.

Looking at the source of AssetLoadException make it clear: “AssetLoadException is thrown when the AssetManager is able to find the requested asset, but there was a problem while loading it.”.

So, how do I find what is causing this? The error is clear but nonetheless really vague.

throw new AssetLoadException(“An exception has occured while loading asset: ” + key, ex);

The root cause is in the exception. What is catching the exception?

If it was the default handing then the root cause would also be printed as part of the stack trace, with its own stack trace. If something in your code or elsewhere is trying to handle that exception then it needs to getCause() and dump that too.

Ohh, thanks a lot :slight_smile: why didn’t i think about adding a try{}catch{}… Now I should be able to fix the issue, it seems pretty straigtfoward.

In case anyone encounter something similar, here is the little modification:

var mat: Material = null
mat = Main.getAssetManager.loadAsset("Materials/TestMat2.j3m").asInstanceOf[Material]
} catch {
case ioe: AssetLoadException => throw(ioe.getCause);

and the new error: Material instances must be loaded via MaterialKey
at com.jme3.material.plugins.J3MLoader.load(
at com.jme3.asset.DesktopAssetManager.loadAsset(
at com.jme3.asset.DesktopAssetManager.loadAsset(

edit: the solution is to use loadMaterial instead of loadAsset of the assetManager.