Java DAE to OBJ as stream behaves strangely (aspose-3d-19.3.jar/JDK8)

I am converting Collada DAE file exported from the Blender 3.6.5 to Wavefront OBJ as stream wanting to pass it to InputStreamReader, but it seems I am doing something wrong or at least misunderstood Aspose’s stream.getInputStream() option, as normally my code works just fine when I am getting that InputStream from actual existing OBJ file as FileInputStream (I did try to actually save it to an OBJ file instead of a stream and then getting the FileInputStream from it and it works that way, but it’s not what I want, I want direct stream option, of course!), thus I am suspecting abovementioned.

So, I do the obvious magic with the Aspose.3D library:

  • opening my DAE file (opens OK)
  • setting my options (basically just the option to get rid of the MTL file with setEnableMaterials(false))
  • saving it as Aspose’s Stream (saves to Stream OK, tested by checking its length, size and even as array to physically print the content to be 100% sure it is OK)

My next step is what I consider to be a logical one: stream.getInputStream(), but for some reason it (its content) seems to be “null/empty/nada/nichts” as I am getting this error in my NetBeans:

java.io.IOException: java.io.IOException: Underlying input stream returned zero bytes

The block code that reads the content of the converted DAE to OBJ uses the “classic” approach, so the part of my code that matters looks like this (all works fine up until the InputStreamReader inside the try() section):

//-------------------- DEA TO OBJ (AS STREAM) --------------------
Scene scene = new Scene();
scene.open(stringAbsPthToInputFIle);
ObjSaveOptions options = new ObjSaveOptions();
options.setEnableMaterials(false);
try ( MemoryStream dstStream = new MemoryStream()) {
    scene.save(dstStream, options);
    
    // THIS VERY LINE SEEMS TO BE THE PROBLEM
    try ( InputStreamReader file = new InputStreamReader(dstStream.getInputStream(), "UTF-8")) {
        BufferedReader bf = new BufferedReader(file);
        String line;
        while ((line = bf.readLine()) != null) {
            // MY OTHER CODE HERE DEALING WITH THE SPECIFIC LINE FROM THE OBJ FILE
        }
    }
}

I have no clue why is that - am I doing something wrong here or is it a bug in this Aspose.3D version?

If so, can anyone show me (post) actual functional version of my code, please?

@luborablahova

Would you kindly try to use the latest version of the API and see if issue still occurs in your environment. If it does, can you please share the sample file in .zip format so that we can test the scenario in our environment and address it accordingly.

As I said in my other post: I CAN NOT USE ANY VERSION OF Aspose.3D NEWER THAN v19.3, cos that is the last one being compiled using JDK8 which is the version I am using and compiling absolutely all my apps with NetBeans13.

That would require for me huge redesign of all of my apps which I won’t do just to be able run your newer versions cos for some reason you are not providing files compiled with JDK8 for ppl like me that still are using JDK8 (and I would say it is the biggest part of Java users).

Main reason why I won’t be using any newer version is that newer versions of Java (and I did try JDK21 and JDK9 only to run almost immediately back to old great JDK8) introducing hell of a lot problems to all my existing Java code, even some that has no functional replacement at the moment like deploying native dll from inside the JAR file itself at runtime…so no, I would not as I can not, sorry.

As for the test file, sure, here it is:
stream.7z (665.0 KB)

@luborablahova

We requested to test using the latest version of the API only to be sure whether the issue is related to specific version of the API. We are sorry if it created an impression that we did not even read the entire post. Please note that we provide support on the basis of the latest version of the API because any issue reported in the older version is resolved in the higher and the latest version of the API. Therefore, we always recommend using the current latest available version because it contains maximum fixes and the enhancements.

We have gone through the entire description of the scenario you shared and have generated an investigation ticket as THREEDJAVA-299 in our issue management system. We will look into the details of the ticket and inform you as soon as it is resolved. We will share our feedback with you in this forum thread once the ticket is closed. We appreciate your patience in this regard. Please spare us some time.

We apologize for the inconvenience caused.

Oh, I am sorry if I sounded angry or something, no, it was just a bit of a frustration that I cannot move to my next step in my app cos I have to wait for this, nothing else, so all is good with me and thank you for your answer - I will most definitely wait how and if your team would solve this issue.

But if I may ask once again: as I said, I can use only builds that were made with version major 52 which is JDK8 I am using, but your latest builds are made with version major 53 which is JDK9 - well, at least that is how my NetBeans13 is telling me when I tried to use your latest builds, thus my question here: would it be possible for your team to also make builds compiled using/with JDK8 which is still the mostly used Java version out there so I could actually use your newest builds?

I would think about two section in the jar download section of your website, where there would be build with mv53 (JDK9) at the top, and there could be - below it - build made with older yet mostly used mv52 (JDK8), so one can chose what it suits him, hm?

@luborablahova

Thanks for the explanation. Yes, we can try to publish a JDK8 compatible version of the API. However, it will lack some features. We will be looking into this request and let you know once we have some updates.

1 Like

@luborablahova
Rendering now necessitates lwjgl.jar, which isn’t compatible with JDK8. Due to this, we had to raise the minimum JVM version. However, we can create a specialized build compatible with JDK8, albeit without rendering capabilities.
We’ll let you know once we fixed this issue.

1 Like

Oh guys - both of you - this is prolly the best news this year I got so far, thank you so much for this!!!

I do not need rendering ability so absolutely no miss on my side, and I guess most of the ppl using this library using it mainly for the 3D manipulation abilities (in fact you are the only one known Java lib which can do this, amazing stuff) as there are separate free Java renderers thus one can quite easily use those in combo with your library…

Maybe you could just list those missing functions in the JDK8 build under the download section so one would know what he would missing if he uses JDK8 build - I think that would be sufficient info for those willing to use such build.

BTW I am author of one such renderer myself…well, actually a advanced GUI for a renderer bringing many new abilities to the renderer itself (tho it is only my own personal internal tool for my quasy-business).

Can not wait to see the release of JDK8 builds of your newest version - looking forward to that impatiently!

@luborablahova

Thanks for your kind feedback. We will surely inform you in this forum thread once the ticket is resolved.

1 Like

The issues you have found earlier (filed as THREEDJAVA-299) have been fixed in this update. This message was posted using Bugs notification tool by Aspose.3D Team.

@luborablahova
You have two options to utilize the JDK8 version:

Download it directly from: Aspose Repository Browser /java/repo/com/aspose/aspose-3d/23.11.0/

Include the JDK8 classifier in your pom.xml as follows:

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-3d</artifactId>
    <classifier>jdk8</classifier>
    <version>23.11.0</version>
    <scope>compile</scope>
</dependency>

Ensure you define the repository:

<repository>
    <id>aspose</id>
    <name>Aspose.Releases</name>
    <url>https://releases.aspose.com/java/repo</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

These methods will enable you to use the JDK8 version of the Aspose.3D library in your project.

So, I downloaded the newest build for the JDK8 but it still says the same: was made with major version 53 not with 52 (which I am using = JDK8). :neutral_face: :face_with_diagonal_mouth: :worried: :roll_eyes:

Warnings during compilation:

ant -f Z:\\_JAVA_\\DaeToObj -Dnb.internal.action.name=rebuild clean jar
init:
deps-clean:
Updating property file: Z:\_JAVA_\DaeToObj\build\built-clean.properties
Deleting directory Z:\_JAVA_\DaeToObj\build
clean:
init:
deps-jar:
Created dir: Z:\_JAVA_\DaeToObj\build
Updating property file: Z:\_JAVA_\DaeToObj\build\built-jar.properties
Created dir: Z:\_JAVA_\DaeToObj\build\classes
Created dir: Z:\_JAVA_\DaeToObj\build\empty
Created dir: Z:\_JAVA_\DaeToObj\build\generated-sources\ap-source-output
Compiling 1 source file to Z:\_JAVA_\DaeToObj\build\classes
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/ObjSaveOptions.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/Scene.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/utils/MemoryStream.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/SceneObject.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/A3DObject.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/INamedObject.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/utils/Stream.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/SaveOptions.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/IOConfig.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
warning: Z:\_JAVA_\DaeToObj\_JARS_\aspose-3d-23.11.0-jdk8.jar(com/aspose/threed/FileFormat.class): major version 53 is newer than 52, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
10 warnings
compile:
Created dir: Z:\_JAVA_\DaeToObj\dist
Copying 1 file to Z:\_JAVA_\DaeToObj\build
Copy libraries to Z:\_JAVA_\DaeToObj\dist\lib.
Building jar: Z:\_JAVA_\DaeToObj\dist\DaeToObj.jar
To run this application from the command line without Ant, try:
java -jar "Z:\_JAVA_\DaeToObj\dist\DaeToObj.jar"
deploy:
jar:
BUILD SUCCESSFUL (total time: 1 second)

Error when I try to run my app:

run:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/aspose/threed/SaveOptions has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
	at java.lang.Class.getMethod0(Class.java:3018)
	at java.lang.Class.getMethod(Class.java:1784)
	at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)
C:\Users\[user-name-here]\AppData\Local\NetBeans\Cache\13\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\[user-name-here]\AppData\Local\NetBeans\Cache\13\executor-snippets\run.xml:94: Java returned: 1
BUILD FAILED (total time: 0 seconds)

I really sill got the exact warnings/errors as before: I am using NetBeans 13 with Ant for compilations, not Maven (as I think your solution with that code to add is for Eclipse with Maven instead, right?) + there is no pom.xml file in my project anywhere (the only one is the one that comes with your library and it is not .xml but actually a .pom file type tho its internal structure is xml…mindboggling indeed) - I still cannot use it!

Or did you mean to put that .pom file that comes with your library alongside it and add there that missing line of <classifier>jdk8</classifier>? Probably not, cos its internal structure is different as those are not under tag <dependency>.

Can you tell me how to make it when one is using Ant and adding his dependency jar files MANUALLY?
Where to add/edit that <repository> part? Do I guess correctly that it does not work that way with the Ant?

The only mention of the Aspose library file-wise are 3 lines in nbproject/project.properties file like this:

file.reference.aspose-3d-23.11.0-jdk8.jar=_JARS_\\aspose-3d-23.11.0-jdk8.jar
javac.classpath=\
    ${file.reference.aspose-3d-23.11.0-jdk8.jar}:\
javadoc.reference.aspose-3d-23.11.0-jdk8.jar=_JARS_/aspose-3d-23.11.0-javadoc.jar

Sorry to sound dumb (or maybe I actually am JAVA-wise, bah) but I never ever needed to do anything like this before with any other jar I am using so I hope you do understand that this is really “a spaniard village to me” (a popular saying here in my country for cases where one have no clue :smiley:)…so I hope you can tell me how exactly to do this basically step-by-step (fingers crossed).

@luborablahova
I’ll investigate this issue shortly and will update you once the new JDK8 release is prepared, expected to be available next week.

1 Like

Thank you so much for your prompt answer…I thought this release already is for the JDK8?
Nevermind, I will wait for your reply once more hoping you can help me with this.

@luborablahova
Our build tool has the capability to create a specialized version devoid of lwjgl-related code. The JDK8 version was built using a source/target version of 1.8. I will investigate why the class file is version 53 next week, as currently, I’m occupied with a task of higher priority.

I’ve included the JDK8 issue in my task list for next week using our job planning tool.

1 Like

Thank you once again, Lex - I will wait impatiently. :pray:

@luborablahova

Please download the JAR file from this location. Please note that the size of this release file is 2,565,668 bytes. You may initially receive an older version due to the incomplete propagation of CDN invalidation. To ensure you have the correct file, verify that the downloaded file size matches 2,565,668 bytes. Alternatively, you can wait a bit longer and attempt the download again until all CDN edge nodes are synchronized.

1 Like

YES - this file is OK, no warnings nor errors so far. :ok_hand: :+1:
Now I will test it during the day and let you know if all is as it should…thank you very much.

UPDATE:
So, firstly I tested my initial simple example that just takes the dae and coverts it to obj - that works fine, no problem - I also checked that converted obj content and it is filled with data.

But, when I try to actually use it in my real code as a stream using exactly the same dae file - that is the actual way I want to use Aspose, as obj stream from the dae - all works fine until this code line:

InputStreamReader file = new InputStreamReader(dstStream.getInputStream(), "UTF-8")

I checked that dstStream is filled with data by dstStream.getSize(), output is 5098356; = OK.

And then I checked after the InputStreamReader file line by testing file.ready() - result is always false, as I need it few lines later as BufferedReader bf = new BufferedReader(file);, thus for me bf.readLine() is always null so it cannot traverse thru the converted stream thus nothing is rendered.

Did I misunderstood something doing it wrong? If so, can you show me how exactly convert the stream from Aspose to InputStreamReader?

@luborablahova
I’m currently occupied with other tasks. I’ll investigate this as soon as I’m available and provide an update promptly.

Thank you - I will wait.