[Solved] Can't load resources in Intellij plugin

I’ve been trying to add a jmonkey scene to intellij for a couple of days now. I’ve played around with various implementations with varying success, but I keep stumbling across a problem I’ve yet to solve.

Whenever the engine starts I always get the error

com.jme3.asset.AssetNotFoundException: Interface/Fonts/Default.fnt

Which means for some reason the resources are not available on the classpath.

In the stacktrace it shows that DesktopAssetManager was selected:

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:370)

but a few lines before it states:

Aug 09, 2019 1:58:14 PM com.jme3.asset.ImplHandler tryLocate
WARNING: There are no locators currently registered. Use AssetManager.registerLocator() to register a locator.

Which leads me to believe that it didn’t find the configuration file for DesktopAssetManager either (com.jme3.asset.General.cfg and Desktop.cfg). I’ve tried copying them to the classpath of my plugin but there’s no change.

URL url = getClass().getClassLoader().getResource("com.jme.asset.Desktop.cfg");
AssetManager desktopAssetManager =  new DesktopAssetManager(url);
desktopAssetManager.registerLocator("/", ClasspathLocator.class);
desktopAssetManager.registerLocator("/", FileLocator.class);

setAssetManager(desktopAssetManager);

The code I’m “vaguely” following is in the tutorial link below, but I’ve tried various implementations over the last few days and they all have this very issue.

https://wiki.jmonkeyengine.org/jme3/advanced/swing_canvas.html

13:58:00: Executing task 'runIde'...

> Task :compileJava
> Task :patchPluginXml
> Task :processResources
> Task :classes
> Task :instrumentCode
> Task :postInstrumentCode
> Task :jar
> Task :prepareSandbox

> Task :runIde
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.ide.ClassUtilCore to field sun.net.www.protocol.jar.JarFileFactory.fileCache
WARNING: Please consider reporting this to the maintainers of com.intellij.ide.ClassUtilCore
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-08-09 13:58:06,861 [   2008]   WARN - j.internal.DebugAttachDetector - Unable to start DebugAttachDetector, please add `--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED` to VM options 
Aug 09, 2019 1:58:14 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.2-stable
 * Branch: HEAD
 * Git Hash: 8291d61
 * Build Date: 2019-07-13
Aug 09, 2019 1:58:14 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GTX 1060 3GB/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 431.60
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility
Aug 09, 2019 1:58:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_547eeefb57db4499\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_547eeefb57db4499\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_547eeefb57db4499\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_547eeefb57db4499\nvldumdx.dll
 * Driver Version: null
 * Scaling Factor: 1
Aug 09, 2019 1:58:14 PM com.jme3.asset.ImplHandler tryLocate
WARNING: There are no locators currently registered. Use AssetManager.registerLocator() to register a locator.
Aug 09, 2019 1:58:14 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,6,Idea Thread Group]
com.jme3.asset.AssetNotFoundException: Interface/Fonts/Default.fnt
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:370)
	at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:412)
	at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:173)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:181)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
	at java.base/java.lang.Thread.run(Thread.java:834)


I’m not overly-familiar with how the asset manager works. Clearly it’s not finding any resources. This only occurs whilst initializing the engine in a intellij plugin.

you cant load any resources or just Interface/Fonts/Default.fnt ? i had some issues with Interface/Fonts/Default.fnt when i had it dupplicated in subprojects (with lowercase i think)

not sure how this DesktpAssetManager works tho so cant help here.

Can’t load anything. I suspect it’s probably because I’m seeing the project classpath of the open project in intellij and not my plugins classpath. Intellij documentation doesn’t really help a great deal, either. I guess I’ll just keep looking…

I found the solution, though it’s a bit wierd and intellij-specific so not a lot of point, but at least there’s a solution to the thread. Intellij doesn’t like you setting classpath roots as “/”. If you do, the URL becomes a file path instead of my.jar!/path". So the “trick” is to specify a directory and not “/” - and then in the locator specify “root + “…/” + name”.

1 Like