Platform: Java
Version:
com.aspose
aspose-cad
24.6.1
I have about 800 dwg files, use Aspose.CAD java to parse them to get the xData, about 500 are successfull, but about 200 were failed.
Code Sample:
CadImage image = (CadImage) CadImage.load(stream)
The error is:
class com.aspose.cad.cadexceptions.ImageLoadException: Drawing loading failed: Cannot process loading further due to incorrect file format structure, may be file is corrupted. Index 33292 out of bounds for length 33284
—> class com.aspose.cad.internal.Exceptions.Exception: Cannot process loading further due to incorrect file format structure, may be file is corrupted. Index 33292 out of bounds for length 33284
com.aspose.cad.internal.gJ.j.a(Unknown Source)
com.aspose.cad.internal.gJ.bY.a(Unknown Source)
com.aspose.cad.internal.gJ.bW.a(Unknown Source)
com.aspose.cad.Image.a(Unknown Source)
com.aspose.cad.Image.a(Unknown Source)
com.aspose.cad.Image.g(Unknown Source)
com.aspose.cad.Image.load(Unknown Source)
Remark: already tried in the latest version 24.12, but still failed. We had purchased the license, and now it is using in our project. But how can we solve this issue to let the project proceed properly.
@jim_zhu
The error you are encountering, ImageLoadException
, indicates that there is an issue with loading certain DWG files due to potential corruption or an incorrect file format structure. This specific error message suggests that the index being accessed is out of bounds, which often points to a problem with the file itself.
Here are some steps you can take to troubleshoot and potentially resolve this issue:
-
File Integrity Check: Verify the integrity of the problematic DWG files. You can try opening them in AutoCAD or another CAD application to see if they are indeed corrupted.
-
File Format Compatibility: Ensure that the DWG files you are trying to load are compatible with the version of Aspose.CAD you are using. Sometimes, files created in newer versions of AutoCAD may not be fully supported in older libraries.
-
Update Aspose.CAD: Although you mentioned trying version 24.12, ensure that you are using the latest version of Aspose.CAD, as updates often include bug fixes and improved support for various file formats.
-
Error Handling: Implement error handling in your code to skip files that cannot be loaded. This way, you can continue processing the remaining files without interruption. Here’s a sample code snippet to illustrate this:
try {
CadImage image = (CadImage) CadImage.load(stream);
// Process the image as needed
} catch (ImageLoadException e) {
System.out.println("Failed to load image: " + e.getMessage());
// Optionally log the error or handle it accordingly
}
-
Contact Support: Since you have a purchased license, consider reaching out to Aspose support for assistance. They may be able to provide insights specific to the files you are working with or offer solutions tailored to your situation.
By following these steps, you should be able to identify the cause of the loading failures and take appropriate action to resolve them. If the issue persists, providing specific details about the problematic files to Aspose support could lead to a more targeted solution.
@jim_zhu,
Hello,
could you please share 2-3 such files that failed to load for the latest 24.12 version, so we can reproduce and analyze them?
I tried with Aspose.CAD .net v25.3, it can open the dwg file successed which failed in Aspose.CAD Java.
Aspose.CAD.Image img = Aspose.CAD.Image.Load(“D:\dwg\0952.dwg”);
May be there is bug in Java version.
I found a issue about the .net version in your offical website,
Aspose.CAD for .NET 20.3 - Release Notes,
Untitled.png (29.2 KB)
Would you please help to check, if it is a bug, would you please help to fix it in Aspose.CAD Java version?
Error message in Java version:
Drawing loading failed: Cannot process loading further due to incorrect file format structure, may be file is corrupted. Index 33436 out of bounds for length 33428
PS: I tried the .net version 24.1, still has this issue, but it fixed in 25.3, so, please help to fix it in Java version. Many thanks.
@jim_zhu,
yes, this is possible that there is no error in Aspose.CAD for .NET but it occurs for Java only. Please provide some test file so we can find the source of the error exactly.
The dwg files contains business informations, so I can’t send it out. this the full exception stack trace, It may help you to check. The point of the error is Index 33436 out of bounds for length 33428, may be it was caused by index overflow for the Array. would you please help to check.
class com.aspose.cad.cadexceptions.ImageLoadException: Drawing loading failed: Cannot process loading further due to incorrect file format structure, may be file is corrupted. Index 33436 out of bounds for length 33428
—> class com.aspose.cad.internal.Exceptions.Exception: Cannot process loading further due to incorrect file format structure, may be file is corrupted. Index 33436 out of bounds for length 33428
com.aspose.cad.internal.gJ.j.a(Unknown Source)
com.aspose.cad.internal.gJ.bY.a(Unknown Source)
com.aspose.cad.internal.gJ.bW.a(Unknown Source)
com.aspose.cad.Image.a(Unknown Source)
com.aspose.cad.Image.load(Unknown Source)
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
java.base/java.lang.reflect.Method.invoke(Method.java:580)
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:76)
org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
org.junit.runners.ParentRunner.run(ParentRunner.java:413)
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
org.junit.runner.JUnitCore.run(JUnitCore.java:137)
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
@jim_zhu,
This error and numbers in error message are about the exact file, so in general it is almost useless for us without it. We can only guess what is wrong with the reading at the moment. The problem may be in some other internal procedures performed at reading but not directly in the parsing at all.
Could you please confirm about “PS: I tried the .net version 24.1, still has this issue, but it fixed in 25.3, so, please help to fix it in Java version.”
Did you mean 25.1 .NET version, or 24.1 .NET? Could you please check .NET 25.1 or 24.12? Could you please look at the DWG file version, if all problematic files are of the same DWG version and what is it?
for the same dwg file:
Aspose.CAD .net v25.1.0 --> Success
Aspose.CAD .net v24.1.0 --> Failed
Aspose.CAD Java v24.6.1 --> Failed
Drawing loading failed: Cannot process loading further due to incorrect file format structure, may be file is corrupted. Index was outside the bounds of the array.
@jim_zhu,
OK, so let’s try to load these files in the upcoming Aspose.CAD for Java 25.1. If they could be loaded in Aspose.CAD for .NET 25.1 we expect the same for Java version too.
Tried the Java 24.9, the error was different now, would you please help to check, many thanks!
class com.aspose.cad.cadexceptions.ImageLoadException: Drawing loading failed: Cannot process loading further due to incorrect file format structure, may be file is corrupted. arraycopy: last destination index 35544 out of bounds for byte[35536]
---> class com.aspose.cad.internal.Exceptions.Exception: Cannot process loading further due to incorrect file format structure, may be file is corrupted. arraycopy: last destination index 35544 out of bounds for byte[35536]
May be there are too much elements in the drawing.
@jim_zhu,
Too much elements itself can not cause loading issue, but one particular entity for one particular DWG format version can for instance. We need to find the issue directly and after that we can see the way to fix it. We can not compare changes between versions searching for the possible reason that causes failing for some file (especially for the case with loading of the file problem). We can only test the issue with the latest version available and create a fix for the next future version. We need to reproduce the issue on our side to be helpful, but without the file we can neither reproduce the issue nor verify whether the potential fix is helpful unfortunately.