Lock on jar after

Hello Aspose,

We use your library from an Tomcat(8.5.*) Webapp, but after stopping the webapp from the /manager the file aspose-words-21.3-jdk17.jar cannot be edited and still has an Filelock on it.

We suspect something in the library is preventing Tomcat to unload it from it’s memory. It happens after we load the license.

//Java: load the license:
try ( InputStream lLicenseStream = new BufferedInputStream( 
       AsposeUtilities.class.getResourceAsStream( "/com/......./Aspose.Words.lic" ) ) ) {
      com.aspose.words.License lWordsLicense = new com.aspose.words.License();
      lWordsLicense.setLicense( lLicenseStream );
} catch ( Exception e ) {
  LOG.error( "Error with Aspose Words license", e );



Could you please share the steps that you are using at your end to reproduce the same issue at our end? We will investigate the issue and provide you information on it.

Steps to reproduce the issue:
1. Download and install Tomcat 8.5 (Apache Tomcat® - Apache Tomcat 8 Software Downloads)
2. Enable the /manager of tomcat
3. Extract this zip in the webapps folder so you get: (tomcat/webapps/aspose/WEB-INF)
webapp-aspose.zip (3.6 KB)
4. Add the following files to the webapp:

  • aspose/WEB-INF/lib/aspose-words-21.3-jdk17.jar
  • aspose/WEB-INF/lib/aspose-words-21.3-shaping-harfbuzz-plugin.jar
  • aspose/WEB-INF/Aspose.Words.lic
    5. Start the tomcat
    6. Navigate to /aspose/index.jsp, so the licences are being loaded.
    7. Navigate to /manager and stop the aspose webapp.
    8. Try to modify the aspose-words-21.3-jdk17.jar and see that the file is locked.



We have logged this problem in our issue tracking system as WORDSJAVA-2547. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


This is a native Tomcat problem, especially for Windows. Some files may be locked when the web application is deployed. I found a similar problem here: java - How to delete loaded Jar files in tomcat? - Stack Overflow. But antiJARLocking is a subset of antiResourceLocking ant Tomcat since 8.5 doesn’t include antiJARLocking attribute (Apache Tomcat 8 Configuration Reference (8.5.95) - The Context Container).

So, to prevent such problems, insert the following line into your …\conf\context.xml file:
<Context antiResourceLocking="true">

This issue is closed because it’s not our bug but Tomcat’s own problem.

The issues you have found earlier (filed as WORDSJAVA-2547) have been fixed in this Aspose.Words for Java 22.2 update.