Issue
- We are putting up commons-io on osgi/module folder so it will be readily available to all modules, on our previous version of Liferay (DXP 2024 Q1.7), the commons-io worked, however now we are updating to the latest DXP quarterly release
-
2025-05-13 15:30:46.537 ERROR [liferay/document_library_raw_metadata_processor-2][ROOT:47] bundle com.liferay.portal.tika:1.0.29 (397)[com.liferay.portal.tika.internal.configuration.helper.TikaConfigurationHelper(12174)] : The activate method has thrown an exception
java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipArchiveInputStream
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:534) ~[?:?]
at java.lang.Class.forName(Class.java:513) ~[?:?]
Environment
- 2025.q1
Resolution
-
the issue seems to be related to a classloading conflict between the manually deployed
commons-iolibrary and the internal Tika library used by Liferay. The errorjava.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamindicates that thecom.liferay.portal.tikabundle cannot find the necessary class from thecommons-compresslibrary, likely due to an incompatible version being loaded from the manually deployedcommons-io.
Sincecommons-iois used by other custom modules you have developed, I understand that simply removing it is not ideal. I suggest to create a dedicated OSGi module forcommons-ioand its dependencies, includingcommons-compress. This isolates the library and prevents conflicts with Liferay's internal dependencies. Use the correct versions ofcommons-ioandcommons-compressrequired by your modules and ensure proper package imports and exports in the module'sbnd.bndfile. This approach allows you to keepcommons-ioglobally available while resolving the conflict.
Steps to create a dedicated OSGi module:
1. Create a new Liferay module project using Blade CLI or Liferay Developer Studio.
2. Add the necessarycommons-ioandcommons-compressJARs to the module's/libfolder.
3. Edit thebnd.bndfile:
* AddImport-Packagestatements for any external packages required bycommons-ioandcommons-compress.
* AddExport-Packagestatements to expose theorg.apache.commons.ioandorg.apache.commons.compresspackages, specifying the correct version numbers.
4. Build and deploy the module.
This approach ensures that Liferay's Tika bundle uses the correct version ofcommons-compressprovided by your dedicated module, resolving the conflict. -
the approach above worked for one customer (at the time of writing this article):
I created a new standalone .jar file importing the commons-io and commons-compress, basing its version to the shared-dependencies-apache-commons.
After deploying that, I didn't receive any errors when creating a Virtual Instances and when calling the addCompany() code. This fixed my issue.