DXF load error when maven packaging

has an error using Aspose CAD libraries with Spring Boot Maven project as below :
a. Proudct : Aspose Total for Java(v3.0)
b. Error issue
After Spring Boot Maven packaging ( .jar ), error occurs when loading dxf file by
Image.load() from the codes created “CadImage image = (CadImage) Image.load(sourcePath)” ;
However, it works well in local IDE before the packaging.
c. Version with error : from 21.3 version or newer ; 20.9 version has no this problem.
d. Test OS : Windows 10, Ubuntu 22.04
e. Java being used : OpenJDK 18.0.2
Please check and advise why the problem occurs and how it can be solved.
Your prompt attention to the matter will be appreciated.

f. Error Code:
com.aspose.cad.cadexceptions.ImageLoadException: Image loading failed: Cannot invoke “com.aspose.cad.system.collections.Generic.Dictionary.tryGetValue(Object, Object[])” because the return value of “com.aspose.cad.fileformats.cad.cadobjects.CadBase.h()” is null
at com.aspose.cad.Image.a(Unknown Source)
at com.aspose.cad.Image.load(Unknown Source)

Caused by: com.aspose.cad.cadexceptions.ImageLoadException: Cannot invoke “com.aspose.cad.system.collections.Generic.Dictionary.tryGetValue(Object, Object[])” because the return value of “com.aspose.cad.fileformats.cad.cadobjects.CadBase.h()” is null
at com.aspose.cad.internal.km.k.a(Unknown Source)
… 15 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke “com.aspose.cad.system.collections.Generic.Dictionary.tryGetValue(Object, Object[])” because the return value of “com.aspose.cad.fileformats.cad.cadobjects.CadBase.h()” is null
at com.aspose.cad.fileformats.cad.cadobjects.CadBase.a(Unknown Source)
at com.aspose.cad.internal.gO.a.a(Unknown Source)
at com.aspose.cad.internal.gO.f.b(Unknown Source)
at com.aspose.cad.internal.gO.f.a(Unknown Source)
at com.aspose.cad.fileformats.cad.cadtables.CadVportTableObject.a(Unknown Source)
at com.aspose.cad.internal.gi.g.a(Unknown Source)
at com.aspose.cad.internal.gi.g.a(Unknown Source)
at com.aspose.cad.internal.gi.c.i(Unknown Source)
at com.aspose.cad.internal.gi.c.C(Unknown Source)
at com.aspose.cad.internal.gi.c.s(Unknown Source)
… 16 common frames omitted

@hs.jo,
Hello, could you please attach the DXF file you are using, so we can reproduce?

p7ymwgz7.zip (12.3 KB)

I tested with this file, it works fine in local IDE(v22.6) and packag jar with version 20.9

@hs.jo,
thank you, we will test what’s going on here in the scope of CADJAVA-10782.

any progress on this issue? please let me know

@hs.jo,
please, make sure that when using Aspose.CAD for Java (>21.1) you don’t move the API to another package, the API must remain in com.aspose.cad.

i didn’t move anything.

just get library from maven repository
(Aspose Repository Browser /java/repo/)

  • pom.xml
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>https://repository.aspose.com/repo/</url>
    </repository>
    ...
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-cad</artifactId>
        <version>22.6</version>
    </dependency>
  • java source

import com.aspose.cad.Image;
import com.aspose.cad.fileformats.cad.CadImage;

CadImage image = (CadImage) Image.load(sourcePath);

this is all i did

@hs.jo,
I’m sorry for misunderstanding. Could you please help us further and create empty project with this file and settings you mentioned, so we can run it and see the issue? Thanks.

https://drive.google.com/drive/folders/1Y9U39Jog6gTZT5zaIVXDVTECShdsZKHJ?usp=sharing

here’s link for test code

  • AsposeCadTestSpringProject.zip - project folder

  • AsposeCadTestSpringProject-0.0.1-SNAPSHOT.jar - maven package output

  • 6K8DIMS.dxf - sample file

dxf file place at same path with jar and run below

java -jar AsposeCadTestSpringProject-0.0.1-SNAPSHOT.jar

if run command it occurs error i mentioned.

below is all java code in project

package com.test.aspose.asposecadtestspringproject;

import com.aspose.cad.Image;
import com.aspose.cad.fileformats.cad.CadImage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.File;

@SpringBootApplication
public class AsposeCadTestSpringProjectApplication {

public static void main(String[] args) {
    String sourcePath = ".\\6K8DIMS.dxf";
    CadImage image = (CadImage) Image.load(sourcePath);
    System.out.println("end");

// SpringApplication.run(AsposeCadTestSpringProjectApplication.class, args);
}

}

1 Like

@hs.jo,
thank you, very helpful, working on it.

@hs.jo,
Hello. We tested this case and found that Spring Boot Maven re-assembles library so namespaces are changed which is not allowed use case for our product. Probably, you can use something like this JarClassLoader for your case.