Issue
- The "restClient" object throws an error in a Freemarker template within a Web Content Template, Application Display Template, a Fragment or any other kind.
- The error message displayed on the HTML page is something similar to:
Java method "com.liferay.portal.vulcan.internal.template.RESTClientTemplateContextContributor$RESTClient.get(String)" threw an exception when invoked on com.liferay.portal.vulcan.internal.template.RESTClientTemplateContextContributor$RESTClient object "…"; see cause exception in the Java stack trace.
- No errors are logged in the server logs or browser console.
Environment
- Liferay DXP 7.4 and Quarterly Releases
- JBoss EAP
Resolution
- Add the
allow-non-standard-wrappers="true"
attribute to the<servlet-container>
tag in yourstandalone.xml
file:<servlet-container name="default" allow-non-standard-wrappers="true"> ... </servlet-container>
- This is needed because Liferay's RESTClient uses a dynamic proxy approach (ProxyUtil.newDelegateProxyInstance()) that doesn't comply with JBOSS's strict servlet specification enforcement, and will be eventually documented in the future: Installing on JBoss EAP.
- You also need to verify if your Liferay patch level includes the fix for LPD-42480 (Fixed in 2024.Q3.11+ and 2025.Q1.0+), and request a hotfix if needed.
Additional Information