Unable process mpp if export my program with aspose tasks lib as a jar file

Hi,

So I want export my program with aspose tasks lib into a runnable jar file but I hit with an error.

Exception in thread "main" java.lang.NoClassDefFoundError: com/aspose/tasks/con
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at com.aspose.tasks.auv.c(Unknown Source)
        at com.aspose.tasks.auv.a(Unknown Source)
        at com.aspose.tasks.bat.a(Unknown Source)
        at com.aspose.tasks.avn.l(Unknown Source)
        at com.aspose.tasks.bat.C(Unknown Source)
        at com.aspose.tasks.avn.h(Unknown Source)
        at com.aspose.tasks.bat.q(Unknown Source)
        at com.aspose.tasks.bat.a(Unknown Source)
        at com.aspose.tasks.bat.a(Unknown Source)
        at com.aspose.tasks.bot.a(Unknown Source)
        at com.aspose.tasks.Project.a(Unknown Source)
        at com.aspose.tasks.Project.a(Unknown Source)
        at com.aspose.tasks.Project.<init>(Unknown Source)
        at com.aspose.tasks.Project.<init>(Unknown Source)
        at samplejar.sample.handleTask(sample.java:39)
        at samplejar.sample.main(sample.java:79)
Caused by: java.lang.ClassNotFoundException: com.aspose.tasks.con
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 28 more

Im updating Aspose Tasks (java via Maven) from V20.1 to V20.11 and I don’t see this issue when I using V20.1.

Here’s the sample program I used to test: samplejar.zip (9.6 KB)

@zhilin39

I have opened a ticket with ID TASKSJAVA-1280 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@zhilin39

Can you please provide the source MPP that you are using on your end and which is failing as we need that for further investigation.

@mudassir.fayyaz,

I feel its more of the export/compilation issue rather than processing issue but I still provide you with the sample file. thanks

project_sample.zip (61.9 KB)

@zhilin39

Thank you for sharing the details. We will share feedback with you as soon as the issue will be addressed.

Hello @zhilin39!
Did you try to use Aspose.Tasks for Java 20.12 or Aspose.Tasks for Java 21.2?

Hi, @alexanderefremov1

not yet. have this issue been fixed ? thanks

@zhilin39

Can you please try using the latest Aspose.Tasks for Java 21.3 on your end. If there is still an issue then please share the feedback wit us.

According to our issue tracker the issue has been fixed.

Hi,

Recently I was trying to update Java tasks library from v23.7 to v23.12 and I reencountered the same issue. The Issue happened for v23.8 and onwards but I was trying to update to the latest build. Possible to reopen this topic again? Thanks

@zhilin39 Hi,

I’ve reopened the ticket with the ID TASKSJAVA-1280.
We need some time to investigate the issue.

@zhilin39 Hi,

I can’t reproduce the issue. Could you provide the updated java project?

Hi,

samplejar.zip (8.6 KB)

Here’s my sample java project but this error only occurs when I export it as a runnable jar file. thanks

@zhilin39 Hi,
Thank you for the updated project!
I couldn’t get the exception. Only if the program cannot find the license (NPE) or there are no command line arguments (ArrayIndexOutOfBoundsException). By the way, it’s a bad idea to check for null using the equals call - if the object is null, there will be an NPE.
I even installed Eclipse IDE. Exported as runnable jar both with “Package required libraries into generated JAR” and “Copy required libraries into a sub-folder next to the generated JAR”.
The issue is most likely related to the environment.
Where is Aspose.Tasks library located after the export? And are there any other versions of the library somewhere in classpath?

Hi @vadimyurko,

noted on the bad idea to check for null using the equals call will change it in the future.

I only have the exception when I exported as runnable jar with “Extract required libraries into generated JAR”. Maybe that’s the root cause of the error. I’m not sure why it only occurs for v23.8 onwards.

thanks

@zhilin39 Hi,
I exported with “Extract required libraries into generated JAR” and got the error with Aspose.Tasks 23.7 as well. Are you sure that there is no such error with this version? Or maybe another version doesn’t throw this exception?

Hi @vadimyurko,

I tested with v23.7 and it does not have the runtime error but I do face the error when I try to use the library. But it’s a similar yet different error, I am not too sure if it is the error you are referring to.

This is the error I received when I tried to use the library:

Exception in thread "main" java.lang.NoClassDefFoundError: com/aspose/tasks/con
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)

I tested with v23.6 and I don’t see any runtime error or the error above.

thanks

@zhilin39 Hi,
Thank you for the clarification!
Now I see that the issue is Windows-specific. We will try to fix it in the next release.
As a temporary workaround, you can export your project as a fat jar or export with Eclipse IDE on Linux.

The issues you have found earlier (filed as TASKSJAVA-1280) have been fixed in this update.