[SOLVED] Need help with setting up asset directory in a jme maven project

Hi Friends :slight_smile:

I am trying to convert a jme ant project to maven project by adding pom.xml and removing build.xml and nbproject folder and constructing my src folder to be like this src/main/java/all my packages here now i stuck at setting asset folder. I tried to add asset folder to my classpath inside pom.xml but yet getting asset not found exception.

In this screen shot you can see my project construction and my pom.xml where i am adding classpath of asset folder and the exception.

and here is my code

 Spatial testCube=assetManager.loadModel("Models/TestCube_1.blend");
        rootNode.attachChild(testCube);


I also tried this way

assetManager.registerLocator("assets", AssetLocator.class);

but then it threw NullPointerException exception when loading model in this line
Spatial testCube=assetManager.loadModel("Models/TestCube_1.blend");

here is exception

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
    at com.jme3.asset.ImplHandler.tryLocate(ImplHandler.java:177)
    at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:359)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:416)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:420)
    at com.overthemoon.test.gamecore.TestConventionalAssetLoader.simpleInitApp(TestConventionalAssetLoader.java:43)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
    at java.lang.Thread.run(Thread.java:745)

I hope some one can help me with this, please

Thanks in advance

Okay i could fix it. I was adding asset classpath in a wrong way, my bad. :chimpanzee_facepalm:

 <build>
        <finalName>TestGameCore</finalName>
        <resources>
            <resource>
                <directory>src/main/resources/assets</directory>
            </resource>
        </resources>
    </build>
2 Likes