留言板

Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

thumbnail
Ravi Rupapara,修改在6 年前。

Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

New Member 帖子: 9 加入日期: 16-7-28 最近的帖子
I am facing this issue after upgrading from Liferay GA3 to GA4. java.lang.ClassNotFoundException:

com.liferay.portal.kernel.notifications.UserNotificationManagerUtil cannot be found by com.liferay.portal.template.freemarker_2.0.24

and

java.lang.ClassNotFoundException: com.liferay.portal.service.ServiceContextThreadLocal cannot be found by com.liferay.portal.template.freemarker_2.0.24


I have removed restricted varibles and classes from

Control Panel -> Configuration -> System Settings -> Foundation -> FreeMarker Engine -> Restricted Variables

I am having following code in my portal_normal.ftl file

<#assign userNotificationManagerUtil = staticUtil["com.liferay.portal.kernel.notifications.UserNotificationManagerUtil"] />
<#assign serviceContextThreadLocal = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"] />
thumbnail
Massimo Bevilacqua,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

Regular Member 帖子: 210 加入日期: 16-12-27 最近的帖子
After removed the restricted variables did you restarted the server?

I copied your code in one template and after restarting it works!
thumbnail
Ravi Rupapara,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

New Member 帖子: 9 加入日期: 16-7-28 最近的帖子
Massimo Bevilacqua:
After removed the restricted variables did you restarted the server?


Yes.
It was working in GA3 but after migration to GA4 it has been stopped working.
thumbnail
Massimo Bevilacqua,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

Regular Member 帖子: 210 加入日期: 16-12-27 最近的帖子
Try this:

<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />


Just to understand if it a matter of "staticUtil" or if something goes wrong in your restricted variables
thumbnail
Ravi Rupapara,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

New Member 帖子: 9 加入日期: 16-7-28 最近的帖子
<#assign userNotificationEventLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.UserNotificationEventLocalService") />
<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />


This both working fine. Again I want to clarify that all this was working fine in Ga3. but after migration to Ga4 it is stopped.
thumbnail
Massimo Bevilacqua,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

Regular Member 帖子: 210 加入日期: 16-12-27 最近的帖子
I am using GA4, I just copied your code in one template and deleted the restricted variables.
After server restart it works fine

Could you please make a screenshot of Control Panel -> Configuration -> System Settings -> Foundation -> FreeMarker Engine -> Restricted Variables and post it?
thumbnail
Ravi Rupapara,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

New Member 帖子: 9 加入日期: 16-7-28 最近的帖子
Hello Massimo Bevilacqua thanks for your reply. Please find below attached screenshot.
thumbnail
mika mika,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

Junior Member 帖子: 34 加入日期: 12-11-27 最近的帖子
Has this bug been fixed? I use 7 CE ga3, have removed all restricted variables and classes, restart server, but it still occur
Caused by: java.lang.ClassNotFoundException: com.liferay.portal.service.ServiceContextThreadLocal cannot be found by com.liferay.portal.template.freemarker_2.0.9

My code in web content template:

<#assign serviceContext = staticUtil["com.liferay.portal.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign httpServletRequest = serviceContext.getRequest()/>
thumbnail
manu tomar,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

New Member 帖子: 23 加入日期: 15-1-7 最近的帖子
As in liferay 7 package has been changed so try below code

<#assign serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign httpServletRequest = serviceContext.getRequest()/>
Viacheslav Kravchenko,修改在6 年前。

RE: Liferay 7 Ga4 freemarker unable to load UserNotificationManagerUtil

New Member 帖子: 5 加入日期: 17-1-3 最近的帖子
Hi, Ravi
Have you found the solution to this issue?
I'm trying to use the serviceContextThreadLocal in the web content display template. It works fine when I'm placing the web content display in the layout, but fails when I'm trying to do that in the portal_normal.ftl