[SOLVED] Cannot import saved file after moving custom savable object

Hello again,
in my project, I’ve used a binary importer to save the “game data” as .bzz file.
The game data is contained in a Savable Object called “GameData” and this is the only thing which is normally saved as .bzz file.
I’ve moved my “GameData.java” class in a new package of my project and now I cannot load anymore any previously saved .bzz file, as I get this error:

java.lang.ClassNotFoundException: MyGame.GameData at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at com.jme3.export.SavableClassUtil.fromName(SavableClassUtil.java:171) at com.jme3.export.SavableClassUtil.fromName(SavableClassUtil.java:203) ...

This is how I load the .bzz file:

[java]
BinaryImporter importer = BinaryImporter.getInstance();
importer.setAssetManager(app.assetManager);
GameData loadedData= (GameData) importer.load(selectedFile);
[/java]

Is there any solution? Am I doing anything wrong? :slight_smile:
Thanks in advance,
Axel

I have tried to create a simple application to convert it, but terribly failed (I basically tried to reproduce the old package tree to load the model and save it with the new tree, but failed because I’m saving a JME node which still loads its custom data from the old tree).

Any tip would be extremely appreciated as I really don’t know how to fix this (I seriously need to reuse my old saves)…

Thanks :smiley:

If you still have the source code used to save the old version, use that to load the game data and then export it via XMLExporter (same concept as BinaryExporter). Then you can edit the class names in a text editor and import via XMLImporter.

1 Like
@Momoko_Fan said: If you still have the source code used to save the old version, use that to load the game data and then export it via XMLExporter (same concept as BinaryExporter). Then you can edit the class names in a text editor and import via XMLImporter.

Thanks for your reply, I’ve just solved creating a second application which does the conversion amond the 2 different package trees (1. load the file using the old project tree, 2. convert all the savable files to the new ones, 3. save the file using the new project tree). Long hard work but it worked.

I’ve never noticed XMLImporter/Exporter and this is why I’m so happy you have replied. The difference is that the file will be “readable” by any user, isn’t it?

Again thanks for help! Will mark this question as solved after your reply :slight_smile:

Guys I really cannot find a XMLImporter class in my JME3 library. It that an external library or something? :slight_smile:

Thanks!

http://hub.jmonkeyengine.org/javadoc/com/jme3/export/xml/XMLExporter.html
http://hub.jmonkeyengine.org/javadoc/com/jme3/export/xml/XMLImporter.html

@pspeed said: http://hub.jmonkeyengine.org/javadoc/com/jme3/export/xml/XMLExporter.html http://hub.jmonkeyengine.org/javadoc/com/jme3/export/xml/XMLImporter.html

Thanks pspeed, but I did already find those links in the javadoc, the problem is that those classes don’t exist in my SDK library (SDK 3.0). Pardon my ignorance, do I need to implement them somehow or maybe updating my SDK?

@AXELTOPOLINO said: Thanks pspeed, but I did already find those links in the javadoc, the problem is that those classes don't exist in my SDK library (SDK 3.0). Pardon my ignorance, do I need to implement them somehow or maybe updating my SDK?

You must not have added jme3-library-plugins to your project dependencies I guess.

1 Like

Found it, thanks, going to play with it a bit :slight_smile: