FileNotFoundException for an asset in Distribution

So, I tried a clean and build and that worked. However, if I try and run the application (either through the exe file or launch the jar executable), both return an “IllegalArgumentException”. However, looking at the stack trace, I discovered a “FileNotFoundException” was the real issue here. This happens to be the first asset actually loaded.

java.io.FileNotFoundException: C:\Users\JSC\Documents\JMonk\KnightGame\dist\assets\Textures\testMap.tmx (The system cannot fi
nd the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:651)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:186)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:772)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:277)
at XMLReader.ReadXMLFile.parse(ReadXMLFile.java:169)
at mygame.LevelState.initialize(LevelState.java:171)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:662)
Dec 27, 2013 8:29:18 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0

Now, I know the assets exist in the lib folder that is built with the distribution, but it seems not to look through the lib.
Is this a path issue? I’m fairly certain others may have had this issue, but I tried searching, and the other results turned up a lot of android related issues.

Here is your problem:
mygame.LevelState.initialize(LevelState.java:171)

We can’t see what it is, though.

Maybe you are trying to access a raw File instead of looking it up through the asset manager. Hard to guess for sure.

Oh, you are right. I’ve got this line there:

[java]rxf = new ReadXMLFile(“assets/Textures/” + Main.levels[Main.level_count],assetManager,bas);
System.out.println(rxf);
rxf.parse();[/java]

which goes to my XMLReader, in which i’ve created a SaxParser from Java’s XML reading libraries.

[java]saxParser.parse(xml_to_read, handler);[/java]

The “xml_to_read” is the “assets/Textures/” + … which is the raw path to the file.

Any idea of how to fix/get around this? The saxParser.parse method asks for the raw file path, so I’m not sure how to provide that, unless I manually add the /lib before I clean and built the distributable.

There is no files in the distribution, retrieve your files from the classpath instead of a file. If you did your own Assetloader you did it wrong but as was said, hard to tell how.

Okay. Well, I didn’t do my own AssetLoader, but how does one just load a file as an asset? Using

[java]assetManager.loadAsset(“Textures/testMap.tmx”) [/java]

It gives me a

java.lang.IllegalStateException: No loader registered for type “tmx”

error because my file is “testMap.tmx.” Is there anyway to load any regular file, or must I build my own AssetLoader?

Sorry if this is somewhere in the docs. Just point me there if I’m being retarded. This is my first distribution release and all… :wink:

Again, you can load your file from the classpath if you don’t make your own loader.

Alright, normen, I’m sorry. What does that mean? I know what a classpath means, but if I move around the files, won’t the path change. I must sound like an idiot right now.

@machspeeds said: Alright, normen, I'm sorry. What does that mean? I know what a classpath means, but if I move around the files, won't the path change. I must sound like an idiot right now.

Maybe google “java class resources”

No, the assets folder is added to the classpath root so all paths stay the same (relative to the assets folder).

For “loading files from the classpath”, this is the first google hit:

Both of you are my heroes. Thank you for your patience. normen, your link worked perfectly. If only I understood you earlier.

Thanks!