Free Support Forum -

File locked after calling getDocumentInfo



In a Java web application that uses groupdocs viewer 17.2.0, I am having problems when I try to delete files that were used by the viewer, more especifically, after using getDocumentInfo method from class ViewerHtmlHandler on them. The virtual machine won’t let me delete a file (in java nor in Windows) because it keeps it open. I created the following code that illustrates the problem:

public static void main(String[] args) throws Exception{
    ViewerConfig config = new ViewerConfig();
    ViewerHtmlHandler viewerHandler = new ViewerHtmlHandler(config);
    String file = "C:\\Users\\Jorge Eduardo\\Desktop\\Infolluviaacida.jpg";
    DocumentInfoContainer info = viewerHandler.getDocumentInfo(file);

While this program is sleeping, I am unable to delete the file I used. Is there a method to “free” the file I used on the viewer?

Thanks in advance.

Best Regards,

Jorge Flórez



We are able to reproduce this behavior using GroupDocs.Viewer for Java 17.2.0, however, this issue has been fixed since version 17.5.0. Therefore, we will recommend you to upgrade the API to v17.5.0 or greater.


Thank you for your reply. The company is considering to use a newer version, but it seems it will take some time.



Sure, please take your time.