[SOLVED] AssetNotFoundException: Models/X on Maven

Hi guys, this is my first post so I’ll introduce myself, I’m toneddu2000, I’m creating hobby games with the FTEQW game engine (a fork of the Quake 1 engine), but I feel I need something more ‘structured’ for my projects, so some day ago I tried for the first time JME (I knew ) and the documentation is great, so many examples, I really like it. Unfortunately my journey quite immediately stopped since I created a simple project creating a class extended by SimpleApplication and everything works except loading assets.
If I insert this line

assetManager.loadModel("Models/Test/test.glb");

At run JME prompts this error:

AssetNotFoundException: Models/Test/test.glb

I’m not using the SDK, but instead I’m using NetBeans with maven and Java v18. This is the pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.toneddu</groupId>
    <artifactId>ExampleGame</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>18</maven.compiler.source>
        <maven.compiler.target>18</maven.compiler.target>
        <exec.mainClass>game.Main</exec.mainClass>
        <!-- JMONKEY ENGINE STUFF -->
        <!-- JMonkey stats -->
        <jme3_g>org.jmonkeyengine</jme3_g>
        <!-- Check the last version -->
        <jme3_v>3.2.0-stable</jme3_v>
    </properties>
    <repositories>
        <!-- Repository for JMonkey Engine dependences -->
        <repository>
            <id>jcenter</id>
            <url>https://jcenter.bintray.com/</url>
        </repository>
    </repositories>
    <dependencies>
        <!-- JMonkey Engine dependences  -->
        <dependency>
            <groupId>${jme3_g}</groupId>
            <artifactId>jme3-core</artifactId>
            <version>${jme3_v}</version>
        </dependency>
        <dependency>
            <groupId>${jme3_g}</groupId>
            <artifactId>jme3-desktop</artifactId>
            <version>${jme3_v}</version>
        </dependency>
        <dependency>
            <groupId>${jme3_g}</groupId>
            <artifactId>jme3-lwjgl</artifactId>
            <version>${jme3_v}</version>
        </dependency>
        <dependency>
            <groupId>${jme3_g}</groupId>
            <artifactId>jme3-plugins</artifactId>
            <version>${jme3_v}</version>
        </dependency>
        <dependency>
            <groupId>net.sf.sociaal</groupId>
            <artifactId>jME3-testdata</artifactId>
            <version>3.0.0.20130526</version>
        </dependency>
    </dependencies>
</project>

Of course, as stated in the guide, I created the assets folder in the main folder (the same folder where pom.xml is placed), and the Models folder is child of assets folder.

Instead, if I write

assetManager.loadModel("Models/Ferrari/Car.scene");

The engine loads successfully the model, because it finds in the C:\Users\myuser.m2\repository\net\sf\sociaal\jME3-testdata\3.0.0.20130526\jME3-testdata-3.0.0.20130526.jar. But (and this is strange), if I copy the exact content of the jar in another folder (for example Ferrari2) in the game assets folder, the loader cannot find the model!

Anyone knows why this problem occurs in my filesystem?

Thanks to anyone for any help!
cheers

Toneddu2000

Your models should be on the assets folder (on the class directory) or you will need to register an asset locator for the asset manager.

Are you using the SDK ?

This is because the models are in asset folder inside the jar and the jar is added to the class directory, so its visible in this case.

Thanks Pavl_G for the super quick response! I’m not using the SDK, just maven and netbeans. For the asset locator, I forgot to mention earlier that I tried also to use FileLocator, that should extend the interface AssetLocator

FileLocator fl = new FileLocator();
fl.setRootPath("C:\\myprojects\\ExampleGame");

(tried with forward slashes,backslashes, trailing or not)
before loading models, but still no success

You need to register it with your assetManager :
On your void simpleInit() :

assetManager.registerLocator("C:\\myprojects\\ExampleGame", FileLocator.class);

FileLocator class will automatically look out for your root path to load your assets.

yes, that did the trick, but I had to add \assets at the end, like this:

assetManager.registerLocator("C:\\myprojects\\ExampleGame\\assets", FileLocator.class);

Thanks a lot Pavl_G for your great support!

2 Likes