0
votes

I have to get ThemeDisplay() in web-content to compare page title. I am using <#assign serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext()> To get service context, but it's throwing freemarker exception mentioned below:

No error description was specified for this error; low-level message:
 java.lang.ClassNotFoundException: com.liferay.portal.kernel.service.ServiceContext cannot be found by com.liferay.portal.template.freemarker_2.0.29

----
FTL stack trace ("~" means nesting-related):
    - Failed at: #assign service = staticUtil["com.lif...  [in template "20155#20195#54243" at line 21, column 1]
----

FYI: I already enabled freemarker engine setting in control panel freemarker engine. Also in portal-ext.properties file.

2
are you sure that this kernel class should be available in this context ?André

2 Answers

3
votes

I just tried in my freemarker template the following:

<#assign
serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext() />

and it works as of Liferay 7 GA5. Are you sure you have correctly enabled the Freemarker variable? To verify:

  • Click Menu -> Control Panel -> Configuration -> System Settings
  • Search for freemarker and hit enter
  • Click the three vertical dots -> Edit
  • Change staticUtil to something like nonExistent (just removing brought it back for me afaik).
  • Shut off your server and remove the setting from your portal-ext.properties file. It's not necessary.

How about now?

1
votes

Thanks guys for your precious responses, I found that it's not working for me, because i am using embedded web-content. And in that case it's not working :)

Sorry for less explain in my question. Actually i didn't know that embedding web-content in theme is a different case.