Posts

Liferay Keycloak integration - SSO and SLO implementation

Liferay Keycloak - Single Sign On / Single Logout Overview Previous article ( https://lifedev-solutions.blogspot.com/2019/10/liferay-keycloak-integration-using.html ) describes steps to configure Keycloak SSO Authorization in Liferay using OpenID Connect Provider. However, this approach has several limitations: - it can't be used as a default login mechanism: user needs to click "Sign In", chose "OpenId Connect", select "OpenId Connect Provider", and only then he is redirected to the Keycloak sign-in form; - After logging out from Liferay user stays logged in in Keycloak. This article will show how to overcome these issues. SSO with Servlet Filter For automatic redirection to Keycloak's Sign In form the servlet filter may be implemented: @Component ( immediate = true , property = { "servlet-context-name=" , "servlet-filter-name=Keycloak Login Filter" , ...

Fix AMD Loader issue for jQuery Plugins

Image
 Fix AMD Loader issue for jQuery libraries Prerequisites Custom portlet has included jQuery library, sample: com.liferay.portlet.header-portlet-javascript=/js/jstree.js" Error Javascript error during loading portlet:   Fix Modify the library source: ( function (factory) { "use strict" ; if ( typeof define === 'function' && define.amd ) { define ([ 'jquery' ], factory); } else if ( typeof module !== 'undefined' && module . exports ) { module . exports = factory( require ( 'jquery' )); } else { factory( jQuery ); } }( function ($, undefined) { ...   Replace the 'define.amd' with false to fix the AMD loading issue.   P.S. Related article for including jQuery into theme: https://lifedev-solutions.blogspot.com/2019/10/include-jquery-plugin-into-theme.html

Fixing PWC6188 JSTL Error on JSP

Fixing PWC6188 JSTL Error on JSP Prerequisites Portlet module with JSTL core included on JSP: <%@ taglib uri =" http://java.sun.com/jsp/jstl/core " prefix =" c " %> Error Such exception may be thrown after portlet deployment: 2020-03-18 17:42:26.302 ERROR [http-nio-8080-exec-8][PortletRequestDispatcherImpl:295] Unable to dispatch request: /view.jsp(1,1) /init.jsp(3,66) PWC6188: The absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved in either web.xml or the jar files deployed with this application 2020-03-18 17:42:26.303 ERROR [http-nio-8080-exec-8][PortletServlet:112] javax.portlet.PortletException: org.apache.jasper.JasperException: /view.jsp(1,1) /init.jsp(3,66) PWC6188: The absolute uri: http://java.sun.com/portlet_2_0 cannot be resolved in either web.xml or the jar files deployed with this application javax.portlet.PortletException: org.apache.jasper.JasperException: /view.jsp(1,1) /init.jsp(3,66) PWC6188: The absolute uri: http...

Configurable Scheduled Task (Cronjob) in Liferay DXP

Configurable Scheduled Task  Overview This article will explain and give you an example of configurable scheduled task. It may be enabled or disabled on-the-fly, cronjob expression for the task may be also changed dynamically. Example This is an example of scheduled task, which uses custom OSGi configuration: ______________________________________________________________________________ import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.messaging.BaseMessageListener; import com.liferay.portal.kernel.messaging.DestinationNames; import com.liferay.portal.kernel.messaging.Message; import com.liferay.portal.kernel.scheduler.*; import org.osgi.service.component.annotations.*; import java.util.Date; import java.util.Map; @Component( configurationPid = MyConfigurationKeys.MY_CONFIGURATION_ID, //todo 1: - set configuration ID immediate = true, property = { }, ...

Override OSGi Component Properties

Image
Override OSGi Component Properties Overview You may need to change some properties for Liferay's OSGi  @Component  in order to customize the built-in behavior, but you don't want to override the whole component. Fortunately, there is an easy way to achieve this. This article will explain how to do this. Sample scenario Let's say, you want to add the "Notifications" portlet to a user profile page. But when you try do this - you can't find this portlet among the available ones: When you check the sources - you'll find out, that "Notifications" portlet is hidden: Obviously, you just need to change the display category. But this is the internal Lifeay code, which you can't just modify. Fortunately, all those properties are easy customizable. Here are the required steps: Create a  [Component-Classname].config  class in  [Liferay]/osgi/configs  folder; Add properties you need to override inside the created file; Restart Lifer...

Gradle workspace: dependencies and modules management

Gradle workspace: dependencies and modules management Overview This article explains how to manage dependencies in your Gradle workspace project, use global dependencies, define configuration, and filter sub-modules. Dependencies management If you have a multi-module project - you probably have a lot of common dependencies in your modules, and you want to reuse them from a single place. This way you'll not need to update a single dependency version in tens of modules, but just update it in one place. The dependencies in your modules can be different: Liferay dependencies  - those ones, exposed by Liferay; Third-party dependencies  - not defined in Liferay. And approach is different for those types. For Liferay dependencies - you can enable  The Target Platform . For third-party ones - you may use global dependencies. Global dependencies You may define global dependencies in the root of your workspace, and then reuse them in different modules. ...

Liferay Target Platform

Enabling the Target Platform What is the Target Platform? Target Platform is a set of Maven's BOMs, which define all the exposed artifacts (Liferay's and third-party ones) in a specific Liferay version. Those BOMs are listed  here . Why we need it? You need target platform for dependencies versions management: this way you don't worry about the specific library versions, and just use the ones Liferay exposes. For example, when you use target platform - Gradle dependencies, like: compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "4.4.0" compileOnly group: "com.liferay", name: "com.liferay.journal.api", version: "4.2.0" compileOnly group: "com.liferay", name: "com.liferay.journal.service", version: "5.0.18" compileOnly group: "com.liferay", name: "com.liferay.dynamic.data.mapping.api", version: "5.2.0" will ...

Creating Themes for Liferay 7.3

Image
Building Theme for Liferay 7.3 Overview This article describes how to create, build and deploy a theme for Liferay 7.3 Prerequisites You should have Liferay 7.3 (with Liferay workspace) and Node (v10.x+) installed already Theme Creation Navigate to [project_root]/themes folder in terminal ([project_root] - root folder of your Liferay workspace project). Install   generator-liferay-theme   globally: npm i -g generator-liferay-theme Check   https://www.npmjs.com/package/generator-liferay-theme   for more details Install Yeoman ( https://yeoman.io/ ) globally: npm i -g yo Create the liferay theme with   yo liferay-theme   command: Answer required questions: define theme name and ID, choose deployment strategy (Local App Server), Liferay version (7.3) and site url ( http://localhost:8080 ) Theme Build and Deployment Navigate to created theme folder: cd demo-liferay-theme Install Gulp ( https://gulpjs.com/ ) with npm: npm ins...

Manual JDK Installation on Linux

Manual JDK Installation on Linux You may install JDK with   sudo apt-get install   command, but in this case you don't control which exactly version will be installed. If you need specific version (for example, "jdk1.8.0_144") - it's better to install it manually. Here are simple steps for this: Download JDK version you need from the official web site:   https://www.oracle.com/technetwork/java/javase/downloads/index.html Unpack it (for example, to   /opt/java   folder) Create symbolic links for   java   (and also for Java compiler - javac , and Java Web Start -   javaws ): Go to   /usr/bin   folder: cd /usr/bin/ Check if there are already sym links: ls -al | grep java Remove old symbolic links (if they exist): sudo rm -Rf java sudo rm -Rf javac sudo rm -Rf javaws Create new symbolic links to required Java version: sudo ln -s /opt/java/jdk1.8.0_144/bin/java java sudo ln -s /opt/java/jdk1.8.0_144/bin/javac ja...