Answers to Liferay Interview Questions
Following are the answer to 50 Liferay Interview Questions that I had posted earlier. I got so many requests that I thought it would be better to provide the answers.
The answers given below may not be complete and are brief so that they set the direction of your thought. There is not much documentation available for Liferay so you will have to explore the server and play with the server to know more about it.
Note: Answers to following question numbers will be added later. I thought of sharing the answers at the earliest.
9 12 19 22 23 28 29 30 32 41 43 47 48 49 50
1) What are the various ways in which you can customize the default behavior of Liferay that ships to you?
Ans) One can customize Liferay by writing:
2) What is the difference between a Liferay Hook and Liferay EXT?
Hooks is a feature to catch hold of the properties and JSP files into an instance of the portal as if catching them with a hook. Hook plugins are more powerful plugins that come to complement portlets, themes, layout templates, and web modules. A hook plugin is always combined with a portlet plugin. For instance, the portlet social-portlet is a portlet plugin for Social Office with hooks. In general, hooks would be very helpful tools to customize the portal without touching the code part of the portal. In addition, you would use hooks to provide patches for the portal systems or social office products.
source:Liferay Portal 6 Enterprise Intranets
EXT is used to customize and extend the Liferay portal. EXT builds a new ROOT webapp and replaces by a huge build mechanism your existing Liferay portal.
The Liferay EXT Environment is where you would ideally make changes to the portal itself. In other words, this is where you customize or “extend” the portal. You may ask, “Why can’t we just make the changes to the portal source directly?” The answer is that you technically CAN, but if and when you have to upgrade, you will have a tough time sorting out what is out-of-the-box and what is customized. EXT Environment keeps things separate.
3) Suppose I want to customize the behavior of Calendar portlet that comes out of the box with Liferay, how can I do that?
Ans: The behavior of Calendar portlet can be modified using EXT or write a separate Calendar portlet meeting the user requirements.
4) How will you configure Liferay to authenticate users from LDAP?
Ans: Go to configuring liferay with LDAP
5) What is inter portlet communication and how can that be achieved?
Ans: Inter portlet communication (IPC) was introduced in JSR 286
6) What is the difference between view and edit modes of a portlet?
Ans: view mode is what is displayed a user logs in to the liferay portal and various portlets are displayed to him.
edit mode is the configuration options that are displayed when the edit button is clicked on the portlet.
7) What is service.xml and how will you use Liferay service builder?
Ans: service.xml is a configuration file which consists the details for database entities that are used in a portlet. The service builder uses the service.xml to generate the DAO/DTO classes for a portlet.
service.xml is also used by the Liferay server to create the database tables and columns for entities mentioned in service.xml.
8 ) Suppose I have a portlet written for Liferay 5.2.3 and I want to run it on Liferay 6, how can I do that? What if I get some spring and hibernate related exceptions with Liferay 6?
Ans: It is very difficult to find the technology updates done in Liferay versions. The plugins SDK was modified in Liferay 6 so if your Liferay 5.3 portlet doesn’t run properly on Liferay 6 then it is better to write a new portlet for Liferay 6 rather than trying to modify the portlet or source code for Liferay 6.
9) There is a requirement from the client that out of 4 portlets that you have written only 2 should be visible to a particular category of users. How will you achieve that? What if some fields in the remaining 2 portlets have also to be controlled based on user role?
10) What is the purpose of portal-ext.properties?
Ans: portal-ext.properties contains various configuration parameters. These settings can be modified or further settings can be added. For example, there is no existing section for database pool in portal-ext.properties but one can add the same as described in question 25.
11) What steps will you follow to change the layout and theme of the portal pages?
Ans: Follow this excellent guide for Liferay theme and layout customization
12) Suppose I want to change the background color of the footer in Liferay, what steps should I follow?
13) Which JSR is being implemented by Liferay?
Ans: JSR 286 which is the reference for Portals from Oracle.
14) What improvements would you like to see in Liferay 6 portal?
Ans: There is no end to what features a CMS server can provide. For good and valid points read the following which are the changes done in Liferay 6.1.
a) Documents, video, audio, images, and other media types are now stored in a single unified library.
“Speaking my language”—For each document type (i.e., financial report, surveillance video, etc.) administrators can customize metadata (i.e., author, reporting period, etc.) into terms familiar to the end user.
b) Mount multiple repositories (e.g. Liferay, Alfresco, Documentum) while maintaining a common UI.
Website planning and updating made easy—Multiple teams can work on several variations of a site simultaneously (e.g. Halloween, Thanksgiving, Christmas variations) and schedule publication dates for each.
c) Enhanced staging means automatic versioning with history, undo support at the site and page level, and preview based on scheduled publications.
d) Specific pages and page areas can be designated as user customizeable
Dynamic site templates become an option—changes to the parent template force changes on any associated children sites.
e) Users can create Sites without the need to designate ties to Organizations or Communities.
Direct links between web content enables users to specify relationships, such as linking an invitation list to a Christmas party calendar event.
f) Data lists can be published as workflow-enabled forms that capture information such as an RSVP, tasks tracking and managing issues.
g) Open participation is encouraged in 6.1—users who have yet to create Liferay accounts can still rate content and have their say in forums, message boards, and wikis.
15) There are 1000 users using the portlet developed by you, how will you take care of transaction management.
Ans: There is no need to worry about transaction management when using the Liferay server. The server itself takes care of transactions. The code generated using Service Builder can also be used with the need to think about transaction management.
16) A client has two different portal applications for Sales and HR department. The client wants to run these portal applications on same server but with separate URL’s like http://[ip]:[port]/sales and http://[ip]:[port]/hr. How will you achieve that?
Ans: Two instances of the server can be made to run on single machine which will make the two instances to run on different ports but with same IP address. The configuration for running multiple Liferay servers on single machine is dependent upon the server being used like Tomcat, JBoss and GlassFish etc.
The steps to run multiple Tomcat instances on Linux are given Run Multiple Tomcat Instances.
17) What are the minimum Java methods one needs to override in order to write a portlet?
Ans: One needs to override the doView(RenderRequest renderRequest, RenderResponse renderResponse) method after overriding the MVCPortlet class.
18) How will you make the user to go from one JSP to another JSP page in a portlet?
Ans: The hyper links to other JSP pages should be encoded using renderURL tags as shown below:
&lt;portlet:renderurl&gt;&lt;portlet:param name=&quot;jspPage&quot; value=&quot;/myPage.jsp&quot;&gt;&lt;/portlet:param&gt;&lt;/portlet:renderurl&gt;
The use of these render tags causes the next JSP page to open within the portlet window. If the links don’t use render tags then the next JSP will open in a new window/tab in the web browser.
19) While building a service using service builder, what is the purpose of specifying remoteservice=true in service.xml?
20) How to control the category in which the liferay portlet created by me will be displayed?
Ans: The category of liferay portlet can be controlled by using liferay-display.xml. The category is configured by adding the following:
&lt;display&gt; &lt;category name=&quot;category.admin&quot;&gt; &lt;portlet id=&quot;9&quot; &gt;&lt;/portlet&gt; &lt;portlet id=&quot;40&quot; &gt;&lt;/portlet&gt; &lt;portlet id=&quot;79&quot; &gt;&lt;/portlet&gt; &lt;portlet id=&quot;80&quot; &gt;&lt;/portlet&gt; &lt;/category&gt; &lt;category name=&quot;category.cms&quot;&gt; &lt;category name=&quot;category.alfresco&quot;&gt; &lt;portlet id=&quot;91&quot; &gt;&lt;/portlet&gt; &lt;/category&gt; &lt;/category&gt; ... &lt;display&gt;
21) What is hot deployment feature of Liferay? Where will you place your portlets for them to be deployed without server restart?
Ans: Hot deployment of Liferay portlets allows one to deploy/re-deploy portlets without the need to restart the Liferay server. For hot deployment one can use the deploy target of ANT build script that ships with Liferay or use Eclipse plugin which also internally uses this ANT script.
22) Does Liferay support email notifications out of the box for portlets involving workflow?
23) What is the purpose of mode and persistence packages which are created by the Liferay service builder?
24) If there are 3 portlets and all of them need to talk to different database systems (say MysSQL, Oracle and SQL Server) because of some legacy application requirements. How will you make them connect to different databases?
Ans: Liferay server doesn’t support multiple database connectivity out of the box. One needs to use JDBC or other database interaction technologies in order to use different databases for various portlets.
25) Can you configure the database connection pool created by Liferay?
Ans: One can configure database connection pool by editing portal-ext.properties by adding the following snipped. The portal-ext.properties file is present in [tomcat_home]/webapps/ROOT/WEB-INF/classes/
# # Liferay can use C3PO, DBCP, or Primrose for connection pooling. See # com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean for the actual # implementation. It is important to understand the strengths and weaknesses # of each provider so that you can choose the best one that fits your # deployment scenario. Provider specific properties can also be passed along # directly to the provider. For example, the property # &quot;jdbc.default.acquireIncrement&quot; is read by C3PO, the property # &quot;jdbc.default.maxActive&quot; is read by DBCP, and the property # &quot;jdbc.default.base&quot; is read by Primrose. # # The default provider is C3PO. # jdbc.default.liferay.pool.provider=c3po #jdbc.default.liferay.pool.provider=dbcp #jdbc.default.liferay.pool.provider=primrose # # The following properties will be read by C3PO if Liferay is configured to # use C3PO in the property &quot;jdbc.default.liferay.pool.provider&quot;. See # http://www.mchange.com/projects/c3p0/index.html#configuration for a list # of additional fields used by C3PO for configuring database connections. # jdbc.default.acquireIncrement=5 jdbc.default.connectionCustomizerClassName=com.liferay.portal.dao.jdbc.pool.c3p0.PortalConnectionCustomizer jdbc.default.idleConnectionTestPeriod=60 jdbc.default.maxIdleTime=3600 jdbc.default.maxPoolSize=100 jdbc.default.minPoolSize=10 jdbc.default.numHelperThreads=3 #jdbc.default.transactionIsolation=1 # # The following properties will be read by DBCP if Liferay is configured to # use DBCP in the property &quot;jdbc.default.liferay.pool.provider&quot;. See # http://commons.apache.org/dbcp/configuration.html for a list of additional # fields used by DBCP for configuring database connections. # #jdbc.default.defaultTransactionIsolation=READ_UNCOMMITTED jdbc.default.maxActive=100 jdbc.default.minIdle=10 jdbc.default.removeAbandonedTimeout=3600 # # The following properties will be read by Primrose if Liferay is configured # to use Primrose in the property &quot;jdbc.default.liferay.pool.provider&quot;. See # http://www.primrose.org.uk/primrose3/primroseConfig.html for a list of # additional fields used by Primrose for configuring database connections. # jdbc.default.base=100 #jdbc.default.connectionTransactionIsolation=TRANSACTION_READ_UNCOMMITTED jdbc.default.idleTime=1800000 jdbc.default.numberOfConnectionsToInitializeWith=10
26) Can you list down various tools and frameworks used by Liferay? e.g. It uses Lucene for search
Ans: One can go through the source code of Liferay and list the toll and technologies being used. I am listing my list here:
27) Suppose a client is pursuing a Liferay based solution to their requirements, what non-functional clarifications will you ask from the customer?
Ans: The non-functional requirements to look out for are:
a) Automated Startup on booting server
b) Automated database backup
c) Concurrent access to users
d) Ability to add more user roles
28) Is there a build number associated to a portlet assigned by the service builder? Where can we find the current build number?
29) Have you tried the Liferay 6 Eclipse plugin? What all limitations have you found?
30) How do you log events in a portlet? Do I need to configure Log4J for every portlet or is there a common place where one can configure Log4J so that all Liferay portlets can use logging API?
31) Do you know how to update your setup of Liferay 5.2.3 to Liferay 6?
Ans: Liferay website itself lists the steps for upgrading from 5.2.3 to Liferay 6. One should be though aware of how to take database backup and how to patch Liferay in general.
32) Can I run my Struts 1.3 based legacy application as a portlet application? How?
Ans: Yes it is possible to convert legacy application into a portlet by making the legacy application to follow the requirements of a Liferay plugin and then deploying the same on Liferay server.
33) Is it a good design to meet the customer requirements by creating a single portlet or splitting them into multiple portlets? What criteria will you use to split the functionality into multiple portlets?
Ans: It is better to split multiple requirements into individual portlets and the use inter-portlet communication for meeting the business requirements. The advantage of splitting functionality is enhanced usability, reduced coupling, better maintainability. Using the typical requirements, one can create separate portlets for Create, Modify, View, Delete and Search of each entity but you should have the user in confidence before making any UI decisions.
34) What advantages do you see in running the Liferay portal application on a application server like JBoss than running it on a web server like Tomcat?
Ans: The decision about using application or web server is totally dependent on the fact that some portlets may be using EJB/JMS and hence would require application server instead of web server. As far as Liferay is concerned, there is no difference in features provided by Liferay depending upon server.
35) What all other portals have you heard of? How do you compare them to Liferay?
Ans: Other vendors have also rolled out portals which are reference implementation of JSR 286. The list includes:
Oracle WebLogic Portal
IBM Websphere Portal
36) How will you implement i18n in a portal application? What if you want the user to choose his language preference?
Ans: Follow the excellent guide on Liferay Internationalization
37) There is a portlet application for managing images similar to Flickr. The user wants to see the images in full screen. Will Liferay allow you to do that?
Ans: The full screen option can be displayed for any portlet by adding
to the corresponding liferay-portlet.xml of the particular portlet.
38) I have a war file of the portlet which is created using service builder, what is the difference between pasting this war file in the deploy folder of Liferay and application folder of server (like webapps in case of Tomcat)?
Ans: Pasting the portlet in the deploy folder of liferay will cause it to be deployed into the application folder of the server automatically when the server is started.
Copying the portlet war file to application folder of server will also cause the war file to deployed as portlet.
The only difference is that the ant script has deploy target which causes the portlet war to be copied to the deploy folder of liferay server.
39) How will you setup a clustered Liferay portal on 5 servers available to you?
Ans: Clustering involves not only clustering server but also configuring various services within Liferay. A complete guide for Liferay clustering is available Clustering Liferay Tutorial.
40) How much user base can Liferay support without affecting performance?
Ans: There are official numbers released by Liferay as shown below:
41) There is a JRE shipped with Liferay package, do we not need a JDK and what is the purpose of bundled JRE?
Ans: The JDK is required to create liferay portlets but the JRE is required for running the portlets
42) Suppose there is a requirement from client to implement search functionality in Liferay portlet, does Liferay provides any API out of the box to support search?
43) What are the various ways in which one can override the default behavior of Liferay?
44) The service builder can also build WSDL for you. What is the benefit of this feature provided by Liferay?
Ans: Using the build WSDL target of ANT, one can deploy the portlet as a web service. JSR 286 uses the term Web Services for Remote Portals. The steps to create a web service portlet can be found Liferay Web Service portlets.
45) How will you build a portlet that can be added only single or multiple times in to the portal application?
Ans: The instanceable flag should be set to true in liferay-portlet.xml present in the WEB-INF directory of every portlet application.
If the value for this flag is false then a portlet can be added only once in the portal page
46) Is it possible to set a session time out for a portlet which is different from other portlets and the Liferay portal?
Ans: No every portlet can not be configured to have a different session timeout interval than the portal itself. If a portlet should not work after some amount of inactive time period then it can be managed using Ajax calls and keeping track of inactive time in portlet code.
47) What is the flow of HTTP request in Liferay?
48) The JSPPortlet.java extends the MVCPortlet.java class. What purpose does MVCPortlet.java fulfill?
49) How do you perform Junit tests on your portlet? How do tackle the dependency on the MVCPortlet.java?
50) Is it mandatory to have the view logic in view.jsp? Can one configure some other JSP (say MyJSP.jsp) to be default view page than view.jsp?