We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NullPointerException is thrown when using addClone() method

I’m experiencing a strange behaviour. On one system (Windows 7), I’m getting a NullPointerException when I try to use the addClone method (as well as in other situations). On the other hand, on a different computer (Windows 10) I don’t get any exception.
I was able to reproduce this behaviour in a minimal program. Consider the class (NB the file empty_presentation.pptx is a file containing a single, empty slide):

import com.aspose.slides.ISlide;
import com.aspose.slides.Presentation;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class AsposeDebugging {
public static void main(String[] args) throws IOException {
File file = new File(“empty_presentation.pptx”);
InputStream stream = new FileInputStream(file);
Presentation template = new Presentation(stream);
ISlide firstSlide = template.getSlides().get_Item(0);
Presentation finalPresentation = new Presentation();
finalPresentation.getSlides().addClone(firstSlide);
System.out.println(“Done!”);
}
}

I used Aspose.Slides creating a maven project with the line

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
and adding to the pom.xml file

AsposeJavaAPI
Aspose Java API
https://repository.aspose.com/repo/


com.aspose
aspose-slides
21.1
jdk16

(the tags in the quoted text above are garbled by the message forum formatter; sorry but I don’t know how to prevent it)

On one system (Windows 10) the main() method runs correctly, on another system (Windows 7) it crashes with the following strack strace:

    at com.aspose.slides.internal.mv.class.do(Unknown Source)
    at com.aspose.slides.internal.mv.class.new(Unknown Source)
    at com.aspose.slides.internal.mv.class.for(Unknown Source)
    at com.aspose.slides.internal.mv.class.do(Unknown Source)
    at com.aspose.slides.internal.m4.for.do(Unknown Source)
    at com.aspose.slides.internal.fm.this.if(Unknown Source)
    at com.aspose.slides.internal.fm.this.case(Unknown Source)
    at com.aspose.slides.internal.fm.long.do(Unknown Source)
    at com.aspose.slides.internal.fm.long.<init>(Unknown Source)
    at com.aspose.slides.internal.fm.long.<init>(Unknown Source)
    at com.aspose.slides.internal.fm.long.<init>(Unknown Source)
    at com.aspose.slides.internal.oq.public.do(Unknown Source)
    at com.aspose.slides.o4.do(Unknown Source)
    at com.aspose.slides.o4.do(Unknown Source)
    at com.aspose.slides.o4.do(Unknown Source)
    at com.aspose.slides.ano.do(Unknown Source)
    at com.aspose.slides.oi.do(Unknown Source)
    at com.aspose.slides.ln.do(Unknown Source)
    at com.aspose.slides.o0.do(Unknown Source)
    at com.aspose.slides.ape.int(Unknown Source)
    at com.aspose.slides.ape.boolean(Unknown Source)
    at com.aspose.slides.apb.do(Unknown Source)
    at com.aspose.slides.apb.<init>(Unknown Source)
    at com.aspose.slides.TextFrame.do(Unknown Source)
    at com.aspose.slides.TextFrame.do(Unknown Source)
    at com.aspose.slides.TextFrame.void(Unknown Source)
    at com.aspose.slides.r.do(Unknown Source)
    at com.aspose.slides.rd.do(Unknown Source)
    at com.aspose.slides.rd.do(Unknown Source)
    at com.aspose.slides.bg.do(Unknown Source)
    at com.aspose.slides.ak2.do(Unknown Source)
    at com.aspose.slides.agb.do(Unknown Source)
    at com.aspose.slides.af1.do(Unknown Source)
    at com.aspose.slides.MasterSlideCollection.do(Unknown Source)
    at com.aspose.slides.MasterSlideCollection.do(Unknown Source)
    at com.aspose.slides.SlideCollection.addClone(Unknown Source)
    at com.mycompany.app.AsposeDebugging.main(AsposeDebugging.java:18)

I tried several versions of Aspose, different pptx files in input and different Java versions, but in all cases on the Windows 7 system I get the exception. Any suggestions?

@LorenzoL,
Welcome to our community! Thank you for the issue description. It will take me some time to investigate the issue. I will notify you a little later. Thank you for your patience.

1 Like

@LorenzoL,
I have logged the issue in our tracking system with ID SLIDESJAVA-38469 for further investigation. You will be notified when it is fixed.

1 Like

@LorenzoL,
We cannot reproduce the issue. Please share additional information:

  • Source presentation (“empty_presentation.pptx”)
  • JDK version (full version number)
  • Windows 7 version (build)

According to StackTrace, the problem occurs when Aspose.Slides tries to read information about a font. Could you also check the font accessibility of fonts and share your ‘windows/fonts’ folder from Windows 7 (as an archive)?

Thanks for looking into this. As I mentioned in my original post, I was also unable to reproduce the problem on other systems.

-Windows 7 Enterprise, Service Pack 1, “currentBuild” 7601 ( value from HKEY_LOCAL_MACHINE>Software>Microsoft>Windows NT>CurrentVersion )

-As far as I can tell I have normal access to c:\Windows\Fonts (I tried copying the folder and I was able to do it without problem). Maybe aspose is trying to access a specific font which is not there…?

@LorenzoL,
Thank you for the additional information. Could you please share your fonts from the Windows\Fonts folder?

The system where I’m having the problem is at work, and I’m not allowed to copy large files from there, I can only send email with small attachments. The Windows\Fonts directory is about 250MB zipped (450 MB unzipped), so I cannot easily copy it from the system. I can ask for a special authorization from the system administrator, if you think it’d necessary. What I can do now it to make a available the list of font files there: https://www.dropbox.com/s/8bmj28x624x7r90/fonts.txt?dl=0
Please let me know if I should go on and ask permission. Is there any way to see what fonts aspose is trying to access?

@LorenzoL,
Thank you for the additional information.

Aspose.Slides usually works with embedded and system fonts. Also, external fonts can be specified to use.
More details: PowerPoint Fonts

@LorenzoL,
Our development team investigated the issue and found no problems. We need fonts from the Windows\Fonts folder from the Windows system in which the problem is reproduced for further investigation.

As an update, I regrettably have to report that the problem never went away for me. I’ve tried my best to find anything unusual in the Windows/Fonts directory but failed. Any hint whatever would be appreciated, because I’m really at the end of my tether with this issue.

@LorenzoL,
This issue has been closed since you have not replied for 3 months. We did our best to help you, but we have not managed to reproduce the error. It would be great if you could share additional information for reproducing the error on our side. Then we could continue.

The information on the system are still the same as I described in my original post… unfortunately I was denied the possibility to share the Windows/Fonts directory (because there are some proprietary fonts there – it’s paranoid but there’s nothing I can do for now…). BTW I noticed that the method FontsLoader.getFontFolders() returns an empty array… could this be the reason of the error?

Update: adding the following two lines before the line with the addClone method

String[] dirs = {“C:\WINDOWS\Fonts”};
FontsLoader.loadExternalFonts(dirs);

changes the error message to (my bold):

Exception in thread “main” class com.aspose.slides.exceptions.ArgumentNullException: Value cannot be null.
Parameter name: path1
com.aspose.slides.internal.fs.catch.if(Unknown Source)
com.aspose.slides.internal.on.double.int(Unknown Source)
com.aspose.slides.internal.on.double.do(Unknown Source)
com.aspose.slides.internal.oq.else.do(Unknown Source)
com.aspose.slides.internal.oq.else.goto(Unknown Source)
com.aspose.slides.internal.oq.else.case(Unknown Source)
com.aspose.slides.internal.oq.case.do(Unknown Source)
com.aspose.slides.o4.do(Unknown Source)
com.aspose.slides.o4.do(Unknown Source)
com.aspose.slides.o4.do(Unknown Source)
com.aspose.slides.oi.do(Unknown Source)
com.aspose.slides.oi.do(Unknown Source)
com.aspose.slides.ln.do(Unknown Source)
com.aspose.slides.o0.do(Unknown Source)
com.aspose.slides.ape.int(Unknown Source)
com.aspose.slides.ape.boolean(Unknown Source)
com.aspose.slides.apb.do(Unknown Source)
com.aspose.slides.apb.(Unknown Source)
com.aspose.slides.TextFrame.do(Unknown Source)
com.aspose.slides.TextFrame.do(Unknown Source)
com.aspose.slides.TextFrame.void(Unknown Source)
com.aspose.slides.r.do(Unknown Source)
com.aspose.slides.rd.do(Unknown Source)
com.aspose.slides.rd.do(Unknown Source)
com.aspose.slides.bg.do(Unknown Source)
com.aspose.slides.ak2.do(Unknown Source)
com.aspose.slides.agb.do(Unknown Source)
com.aspose.slides.af1.do(Unknown Source)
com.aspose.slides.MasterSlideCollection.do(Unknown Source)
com.aspose.slides.MasterSlideCollection.do(Unknown Source)
com.aspose.slides.SlideCollection.addClone(Unknown Source)
com.mycompany.app.AsposeDebugging.main(AsposeDebugging.java:39)
at com.aspose.slides.internal.fs.catch.if(Unknown Source)
at com.aspose.slides.internal.on.double.int(Unknown Source)
at com.aspose.slides.internal.on.double.do(Unknown Source)
at com.aspose.slides.internal.oq.else.do(Unknown Source)
at com.aspose.slides.internal.oq.else.goto(Unknown Source)
at com.aspose.slides.internal.oq.else.case(Unknown Source)
at com.aspose.slides.internal.oq.case.do(Unknown Source)
at com.aspose.slides.o4.do(Unknown Source)
at com.aspose.slides.o4.do(Unknown Source)
at com.aspose.slides.o4.do(Unknown Source)
at com.aspose.slides.oi.do(Unknown Source)
at com.aspose.slides.oi.do(Unknown Source)
at com.aspose.slides.ln.do(Unknown Source)
at com.aspose.slides.o0.do(Unknown Source)
at com.aspose.slides.ape.int(Unknown Source)
at com.aspose.slides.ape.boolean(Unknown Source)
at com.aspose.slides.apb.do(Unknown Source)
at com.aspose.slides.apb.(Unknown Source)
at com.aspose.slides.TextFrame.do(Unknown Source)
at com.aspose.slides.TextFrame.do(Unknown Source)
at com.aspose.slides.TextFrame.void(Unknown Source)
at com.aspose.slides.r.do(Unknown Source)
at com.aspose.slides.rd.do(Unknown Source)
at com.aspose.slides.rd.do(Unknown Source)
at com.aspose.slides.bg.do(Unknown Source)
at com.aspose.slides.ak2.do(Unknown Source)
at com.aspose.slides.agb.do(Unknown Source)
at com.aspose.slides.af1.do(Unknown Source)
at com.aspose.slides.MasterSlideCollection.do(Unknown Source)
at com.aspose.slides.MasterSlideCollection.do(Unknown Source)
at com.aspose.slides.SlideCollection.addClone(Unknown Source)
at com.mycompany.app.AsposeDebugging.main(AsposeDebugging.java:39)

Process finished with exit code 1

@LorenzoL,

This usually should not occur. I passed all your additional information to our development team. We will investigate this case further.

1 Like

@LorenzoL,
Unfortunately, our development team still cannot reproduce this issue on our side. But based on investigations of the provided stack traces, our developers found that the issue is related to accessing the fonts folder. The main problem with accessing the fonts folder has been fixed in Aspose.Slides 21.5. Please check the issue with the latest version of Aspose.Slides.