HttpZipLocator questions

assetManager.registerLocator(
                    "https://www.icyboxs.com/icyboxs/Lina.zip",
                    HttpZipLocator.class);

 Node  model =  (Node)assetManager.loadModel("Wlak.gltf");

Node model = (Node)assetManager.loadModel(“Wlak.gltf”);
HttpZipLocator loads GLTF

Will it work?
I tried and I failed. Can you give me an example if it worked?

1 Like

Thank you for your reply

1 Like
com.jme3.asset.AssetLoadException: An error occurred loading Stand.gltf
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:181)
	at com.jme3.scene.plugins.gltf.GltfLoader.load(GltfLoader.java:106)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
	at net.jmecn.HelloArmature.model(HelloArmature.java:321)
	at net.jmecn.HelloArmature.initScene(HelloArmature.java:257)
	at net.jmecn.HelloArmature.simpleInitApp(HelloArmature.java:114)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.google.gson.JsonIOException: java.util.zip.ZipException: invalid distance too far back
	at com.google.gson.internal.Streams.parse(Streams.java:62)
	at com.google.gson.JsonParser.parse(JsonParser.java:84)
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:123)
	... 10 more
Caused by: java.util.zip.ZipException: invalid distance too far back
	at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
	at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:270)
	at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:313)
	at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
	at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
	at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
	at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333)
	at com.google.gson.stream.JsonReader.consumeNonExecutePrefix(JsonReader.java:1576)
	at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:534)
	at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
	at com.google.gson.internal.Streams.parse(Streams.java:46)
	... 12 more

If I download it and use it locally it works fine but if I use a remote node then I get an error

This is the file for the remote node

Quick Googling says that the ZIP is corrupted. Maybe the upload wasn’t completely successful?

For me it gives this error when trying with “HttpZipLocator”:

com.jme3.asset.AssetLoadException: An error occurred loading Walk.gltf
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:181)
	at com.jme3.scene.plugins.gltf.GltfLoader.load(GltfLoader.java:106)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
	at asset.TestHttpLocator.simpleInitApp(TestHttpLocator.java:33)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:548)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:662)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.google.gson.JsonIOException: java.util.zip.ZipException: invalid code lengths set
	at com.google.gson.internal.Streams.parse(Streams.java:62)
	at com.google.gson.JsonParser.parse(JsonParser.java:84)
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:123)
	... 9 more
Caused by: java.util.zip.ZipException: invalid code lengths set
	at java.base/java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164)
	at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:270)
	at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:313)
	at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
	at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
Caused by: com.google.gson.JsonIOException: java.util.zip.ZipException: invalid code lengths set

	at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
	at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333)
Caused by: java.util.zip.ZipException: invalid code lengths set

	at com.google.gson.stream.JsonReader.consumeNonExecutePrefix(JsonReader.java:1576)
	at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:534)
	at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
	at com.google.gson.internal.Streams.parse(Streams.java:46)
	... 11 more

It works fine when loading it locally via “ZipLocator” as already mentioned.

I tried to unzip your file and zip it again with Linux default archive manager and uploaded it to another host but still the same error.
But when I tried to zip it with this online tool: https://www.ezyzip.com it worked. Not sure why!

Hmm, could be also just a bug. It looks so manual way. Lot of code in the HttpZipLocator, all kinds of optimizations for downloading just the right parts. Which is good but probably the ZIP has to be very standard for this to work.

1 Like

@icyboxs can you please fill a bug report on the JME Github page? Issues · jMonkeyEngine/jmonkeyengine · GitHub

Looks like I found the bug in the HttpZipLocator!

After comparing the two zip files (that were generated with the same compression level), I noticed that their entry offsets are different in HttpZipLocator.

Following it, I found that the “extraLen” (Central directory (CEN) header extra field length field offset) used here has different values on these two zip files:

in the zip file created by www.ezyzip.com (and also in the JME’s “wildhouse.zip” that is on google storage), that value is 0 (which is why HttpZipLocator does not show an error) but in the zip file that @icyboxs uploaded and also I created in the Linux archive manager that value is non-zero (36 bytes).

After I take that out from the calculation, the error has gone and it loads fine. So it looks like this

entry.offset += ZipEntry.LOCHDR + nameLen;
2 Likes

And here is the PR :slightly_smiling_face:

2 Likes

issues
I have launched an issue.

However, I do not know whether the issues I initiate meet the issues specification. :face_with_monocle:

Thank you for helping me again

2 Likes

I believe the HttpZipLocator was written for the days of Java Applets. If you are writing a desktop application then I think HttpZipLocator will be pretty awful in general… versus just downloading the .zip once and using that.

1 Like

indeed.
I saw your reply on GitHub.
Java itself has URL functionality and I ignored it :thinking: