Unable to parse an xml file when deployed Webstart on a server

I have been testing my Webstart jMonkey program by uploading it to a server and running the game from there. However, the game crashes when it tries to get an object from a list that should contain questions loaded in from an xml file.

At the start of the game, it loads up all assets including parsing the xml files and adding the questions to a list. During this loading time, the Java Console says “C:UsersChrisDownloadsassetsQuestionsclay.xml (The system cannot find the path specified)”.

So my question is there any restrictions to using the Document Builder process to read an xml file when deployed on the web? I do not get this problem when I run the game locally.

For clarity, here is the code used to parse the xml file, which has no problems when run locally. And the xml file is located in the assets folder.

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

File clayFile = new File(“assets/Questions/clay.xml”);

DocumentBuilder builder = factory.newDocumentBuilder();

Document clayDoc = builder.parse(clayFile);

NodeList clayList = clayDoc.getElementsByTagName(“question”);

getAttrs(clayList, clay);

is the problem my path name for the xml file? would imagine it would just look in the assets folder once it had downloaded the game.

thanks for any help. im just trying figure out what the problem is and can’t find any information when googling.

As you use the assets/ prefix in your application I guess you are working with eclipse. It only works inside the IDE because your project directory is the execution directory of the application when you run it. The assets folder doesn’t exist for the applet, outside your IDE. So just care for having a proper classpath from which you load your data. Either add the assets folder to your project classpath, remove the “assets/” prefix in your application and make sure you include the assets e.g. in your application “fat jar” file. Or make sure your applets assetmanager can access the assets with their current path by adding a locator to the data (the assets/ prefix would require the root folder or jar to contain a folder called “assets” then though). Everything I mentioned is explained in detail in the manual/wiki and/or in the manual of your IDE, so no need to ask “how do I do that”.

Btw, all this is taken care of for you in the SDK, including creating an applet.

Edit: If you use the SDK or set up the classpath with the assets folder in any other IDE, juts load the file from the classpath and not via a File object, you can get inputstreams for resources from the classpath.