[SOLVED] BinaryExporter problem

I must be going crazy … hopefully I am. I have some basic test code that takes in a spatial , exports it to a byte array and saved it to the database. I took the blob data from the database and saved it to a .j3o file and tried to load it into the sdk and looks like the SDK ran in an infinite loop until it ran out of heap.

The Code:

public static void saveSpatial(Spatial spatial, long runtimeUserId, String path, AssetManager assetManager)
	{
		JmeExporter ex = BinaryExporter.getInstance();
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		try
		{
			ex.save(spatial, out);
			setServerData(ASSET_KEY, path, out.toByteArray(), runtimeUserId);
			System.err.println(out.toByteArray());
			out.close();
			assetManager.deleteFromCache(createModelKey(runtimeUserId, path));
		} catch (IOException e)
		{
			e.printStackTrace();

		}

	}

The exception after the SDK tries to load the binary into scene composer:

java.lang.OutOfMemoryError: Java heap space
	at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:149)
	at java.lang.StringCoding.decode(StringCoding.java:193)
	at java.lang.StringCoding.decode(StringCoding.java:254)
	at java.lang.String.<init>(String.java:546)
	at java.lang.String.<init>(String.java:566)
	at com.jme3.export.binary.BinaryImporter.readString(BinaryImporter.java:295)
	at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:181)
	at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:125)
	at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:109)
	at com.jme3.export.binary.BinaryLoader.load(BinaryLoader.java:36)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:259)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:373)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:416)
	at com.jme3.gde.core.assets.SpatialAssetDataObject.loadAsset(SpatialAssetDataObject.java:94)
	at com.jme3.gde.scenecomposer.OpenSceneComposer$1.run(OpenSceneComposer.java:37)
	at java.lang.Thread.run(Thread.java:748)
1 Like

After closer inspection of the binary data in the database I noticed the first two characters where “PK” … typical signature for a zip file. So I unzipped the binary, saved that as a j3o and it loaded up fine. So the SDK can not load zipped .j3o data that the binary exporter produces?? This is 3.2.2 by the way.

2 Likes

SOLVED! Apparently the new version of MySql stores BLOB data in zipped format for you. Go figure :slight_smile:

1 Like