Issue
- When upgrading from Liferay DXP 7.2 to 2025.Q1, setting the
fileMaxSizeproperty in thecom.liferay.document.library.configuration.DLConfiguration.configfile causes an "Unable to cast String to Long" error. The upgrade tool fails with this error because thefileMaxSizeproperty expects a Long value, but the configuration file may contain a String value if not correctly configured.
2025-04-23 18:16:43.737 ERROR [main][UpgradeExecutor:333] Failed upgrade process for module com.liferay.document.library.service com.liferay.portal.kernel.upgrade.UpgradeException: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Long (java.lang.String and java.lang.Long are in module java.base of loader 'bootstrap')
Environment
- Liferay DXP 7.2
- Liferay DXP 2025.Q1 (Quarterly Release)
- MySQL
Resolution
fileMaxSize property with a Long value by appending L to the numeric value. The following steps outline the correct procedure:
-
DXP 7.2 Configuration: In your Liferay DXP 7.2 instance, locate the
com.liferay.document.library.configuration.DLConfiguration.configfile within theosgi/configsfolder. Set the desiredfileMaxSizevalue by adding "L" after the number, enclosed in quotes. For instance, to set a maximum file size of 20MB, use:fileMaxSize=L"20971520" -
DXP 2025.Q1 Configuration: Similarly, in your Liferay DXP 2025.Q1 instance, locate or create the
com.liferay.document.library.configuration.DLConfiguration.configfile in theosgi/configsfolder. Configure thefileMaxSizeproperty using the same format as in the previous step. Ensure the value matches the one set in your 7.2 instance. For example:fileMaxSize=L"20971520" -
Upgrade Process: After configuring both instances, proceed with running the upgrade tool. The upgrade should complete without the "Unable to cast String to Long" error.
This approach ensures that both your existing 7.2 instance and the target 2025.Q1 instance have the
fileMaxSizeproperty correctly configured as a Long value. By following these steps, the upgrade process can successfully handle the property and prevent the casting error.
Alternatively, you can set the maximum file size in the Control Panel UI instead of a config file:
- DXP 7.2 Configuration: In your Liferay DXP 7.2 instance, go to Control Panel> System Settings >Documents and Media> File Size Limits>Maximum File Upload Size
- Adjust the value
- Save the changes
- Shut down the Liferay DXP 7.2 instance
- Upgrade Process: Proceed with running the upgrade tool