[SOLVED] Running JME from outside the JAR…

Hi all,

I have a slightly unusual use-case: I cannot run my JME app with java -jar, but instead need to run my JME app from Matlab, which has a bundled JRE. I get the error message:



[java]java.lang.IllegalStateException: No loader registered for type "fnt"



at com.jme3.asset.ImplHandler.aquireLoader(ImplHandler.java:199)



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



at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:375)



at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:181)



at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:189)



at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)



at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)



at java.lang.Thread.run(Unknown Source)

[/java]



Up until that point all is well. Note that I do need fonts and graphics - this isn’t running headless.



I’ve told it to import all JARs from the dist/lib directory, so I end up with the classpath:



D:/Documents/jMonkeyProjects/Paths1/dist/lib/xuggle-xuggler-5.4.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/xmlpull-xpp3.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/vecmath.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/tritonus_share-0.3.6.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/tritonus_aos-0.3.6.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/stack-alloc.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/slf4j-api-1.6.4.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/nifty.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/nifty-style-black.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/nifty-default-controls.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/lwjgl.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jmeCapture.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jinput.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jbullet.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/javacsv.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-testdata.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-terrain.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-plugins.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-niftygui.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-networking.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-lwjgl.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-lwjgl-natives.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-jogg.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-jbullet.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-effects.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-desktop.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-core.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/jME3-blender.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/j-ogg-vorbisd.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/j-ogg-oggd.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/eventbus.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/audio-send.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/audio-send-natives.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/assets.jar

D:/Documents/jMonkeyProjects/Paths1/dist/lib/Jama-1.0.2.jar

D:/Documents/jMonkeyProjects/Paths1/dist/MyGame.jar

D:/Documents/MATLAB/



Any idea how I can diagnose the problem? When @beatlefan had this error message when also using SimpleApplication in an unusual way, he reported that he:


Got it to work...I had to extract some of the resouces from the jMonkeyEngine3.jar: the Desktop.cfg, and everything in the Common and Interface folders to the working directory and change the first line in Desktop.cfg to use FileLocator.


But now that JME has been restructured into separate jars, I don't know which files are required... had no luck with just Desktop.cfg.

Thank you!
Peter.

Your application isn’t initialized.

Sorry if I’m being dense here @normen - I am calling app.start() - which triggers the JME settings screen followed by the error. Are you saying I should separately be calling initialize() ?

Wait does MatLab use a restricted classloader environment? As in does it only supply class files out of jars to other plugins/modules like OSGI or NetBeans modules do? What version of jme do you use? The desktop.cfg file isn’t used anymore normally.

Thanks Normen. So according to Matlab’s manual, any jar file I tell it about should be made available on the classpath, and then I presume that any class within that should be available…



There is a command to see if a particular Java class has been loaded successfully - so if there’s a class you think would be diagnostic of this problem, I can check if it’s loaded properly…?



I’m using the latest JME 3 beta update release (not nightly). Glad to hear desktop.cfg isn’t used - explains why I couldn’t find it locally!



Your help with this is much appreciated,

P.

So I guess that yes, you cannot load anything but classes from the jar files… This is why the workaround with the desktop.cfg works for your colleague. This ofc makes things a tad more complicated. You can actually register other classpaths to the assetManager, e.g. to load loaders and classes contained in j3o files from them…

The issue is that the jME3-core.jar is trying to access a file “Desktop.cfg” which is in jME3-desktop.jar.

jME3 uses the thread’s context class loader to access this file, so if that class loader does not contain jME3-desktop.jar it won’t be able to load it and you will see this error.

@Momoko_Fan said:
if that class loader does not contain jME3-desktop.jar

.. or only gives access to the actual classes like in OSGI or NetBeans modules

Thank you both, that’s very helpful. I don’t have a Desktop.cfg in the jme3-desktop.jar . So I can confirm - is it still used? And in theory, putting Matlab to one side, should it be picked up if it’s sitting anywhere the classpath?

PS Normen - the JMonkey logo appears in the settings splash screen, which makes me think it’s ok with non-Java files!

Yeah, normally you just need all the jars that come in the lib folder of the nightly or that are created in the lib folder of a SDK project on the classpath.

Sorry, it seems I made a mistake. The file com/jme3/asset/Desktop.cfg is in jME3-core.jar. Its being loaded from com.jme3.app.Application which is also in jME3-core.jar. I can confirm that the jars I have here (latest build) contain the Desktop.cfg file. It seems the issue happens on your side.

MY GOODNESS, the horror of it. Problem solved. Matlab has a bug - sorry, a feature - where the command ‘javaaddpath’ does not simply add to the Java classpath. That would be too simple. Instead, it uses some horrific non-standard classloader - whereas adding jars to a textfile named ‘classpath.txt’ makes things work normally.



Sorry to waste your time.



Pete.

1 Like