Asset not found fresh installation

Hi everyone. I just started using the SDK instead of the engine but I am familar with Jmonkey. I did a fresh install, created a new Gradle game, added the necessary jars in build.gradle, imported some models and it will not load any of them no matter what I do. The show up fine in the scene explorer but when running the application I get an exception.

com.jme3.asset.AssetNotFoundException: Models/town/town.j3o
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:385)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:444)
	at com.mygame.states.PlayState.initialize(PlayState.java:65)
	at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:333)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:363)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:256)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:160)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:201)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:242)
	at java.base/java.lang.Thread.run(Thread.java:834)

The offending code.

// The town
Spatial town = assetManager.loadModel("Models/town.j3o");
town.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
town.addControl(new RigidBodyControl(0f));
physics.getPhysicsSpace().add(town);
localRootNode.attachChild(town);

As you can see, the file exists exactly where it should be and I noted that it also exists in the Gradle dependencies as well.

project-explorer

I have no idea what is going on and could use some help.

2 Likes
1 Like

Not sure this is the best way, but it is how I get the SDK to work better with the Assets project. I add:

runtimeOnly project(':assets')

to the

dependencies {}

block of build.gradle in the main project

5 Likes

Also, when you run a Gradle project with the default build.gradle you’ll notice a bunch of Warnings / Errors output to the Console. To fix / suppress these, you can also add the following:

implementation "org.jmonkeyengine:jme3-plugins:$jmeVer"
implementation "org.jmonkeyengine:jme3-jogg:$jmeVer"

to the

dependencies {}

block of build.gradle

2 Likes

Thanks everyone. I registered the path with the FileLocator class which solves the problem but this should not be necessary. I just don’t know enough about the gradle build files to understand what is missing.

Gradle is a module based building tool, any module (folder) implemented would be on the project path.

So, in this case @peedeeboy has implemented the asset folder as an additional module.

Another way to fix this is packaging the assets into a jar file and referencing the jar relative path (the path from the current directory) in the game jar Manifest using a jar building task (in this case also the asset folder would be available at the project root dir), but this won’t help with testing the project at runtime, so @peedeeboy has so far introduced a better solution.

1 Like