Friday, October 10, 2014

[Liferay] Setting up Liferay 6.2 on vFabric TC Server 2.6

Sometimes, Tomcat is not enough to run Liferay- reasons may include performance, client's wish etc.

So here are the steps on how to configure Liferay instance on tc server 2.6. Same steps can be followed for liferay version below 6.2, at least for 6.1 I have verified.

We have D:\pFiles\LR\tc-instance\ directory where vFabric tc server is installed. And we will use D:\pFiles\LR\tc-instance\liferay62.local\ to install our lifeary instance.

  1. Lets download liferay from sourceforge
    - Liferay Portal 6.2 CE GA2
    Download portal war file - liferay-portal-6.2-ce-ga2xxx.war
    Download Dependencies - liferay-portal-dependencies-6.2-ce-ga2xxx.zip

  2. Unzip/Install tc server to a location of your wish. I installed to D:\pFiles\LR\tc-instance. This directory will be called TCSERVERHOME

  3. Now we need to create a instance of server lets say this name as liferay62. Use the following command.
    tcruntime-instance.bat create -i D:\pFiles\LR\tc-instance\liferay62 liferay62
    This will create a new instance for liferay62 in the  D:\pFiles\LR\tc-instance\liferay62.

  4. Now, lets install Liferay. Extract the dependencies files which we downloaded to
    D:\pFiles\LR\tc-instance\liferay62\liferay62\lib

    NOTE: You might want to know why liferay62\liferay62, In case you want to install multiple instances, you will need multiple data folders for each and similarly deploy folder. Now deploy and data folders will be created in liferay62\data and liferay62\deploy rather than tc-instance\data and tc-instance\deploy.

  5. We need some more files to be copied to lib directory. You can copy them from liferay tomcat bundle. Check the image below and copy those files as well. You need not to copy all the files for your db connector. Just add the one you want.
  6. Now we need to modify some configuration. For ex. memory configs etc.
    Modify the file
    D:\pFiles\LR\tc-instance\liferay62.local\liferay62.local\conf\wrapper.conf
    Change the following lines as per needed configuration
    Last 2 lines may not be present, so you can add them to the file.

  7. Create a directory in conf and add ROOT.xml
    D:\pFiles\LR\tc-instance\liferay62.local\liferay62.local\conf\Catalina\localhost\ROOT.xml


  8. Change common.loader and port number of your choice in catalina.properties file. Make sure you modify both base.jmx.port and bio.http.port 

    common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/lib/ext,${catalina.home}/lib/ext/*.jar

  9. Extract lifeary war file to
    D:\pFiles\LR\tc-instance\liferay62.local\liferay62.local\webapps\ROOT

  10. Starting liferay as windows service, go to D:\pFiles\LR\tc-instance\liferay62.local\liferay62.local\bin and run tcruntime-ctl.bat install

Start your liferay instance, go to D:\pFiles\LR\tc-instance\liferay62.local\liferay62.local\bin and open command prompt. tcruntime-ctl.bat start

To stop server
tcruntime-ctl.bat stop

Your liferay server should be up and running at the port you configured. 

That's all for now.

Wednesday, September 24, 2014

[Liferay] Get preferences of another portlet | Get preferences of Portlet A in Portlet B

Hi,

Sometimes, we need to get preferences of a portlet into another portlet and take action appropriately.

Here is a snippet on how to do so. Suppose we have portlets A and B. We need preferences of A in B.
We can use dynamic query to get all the preferences of the portlet. From B we can use the code below. Replace myportletA with the correct porltetId.

We need to convert com.liferay.portal.model.PortletPreferences to javax.portlet.PortletPreferences to use getValue() or getValues() method.
Hope this helps someone.
Cheers!!!

Monday, September 15, 2014

[Liferay] Use Database to store Liferay documents | Use JCR Jackrabbit with Database | JCRStore

So, Simple steps to use JCR | Jackrabbit with Database..

1. Start a liferay instance with any database you need. For me its, MSSQL 2005 Express Edition.

2. That will create a repository.xml file in data/jackrabbit/ folder.

Below is a default repository.xml file.
 Change the content to include filesystem and persistence manager in this way. Use your correct username and password.
3. Now, Add the properties below in portal-ext.properties file. We need to let liferay know that we are going to store images and document in db via JCR.
com.liferay.portlet.documentlibrary.store.JCRStore is what we need to store documents via JCR.

That's it. Restart your liferay instance and you should see the files being stored in database.

Check my post below to see if database size increases when you add few files.
[SQL Server] Get size of database in SQL Server 2005 

All done.

Until next time. :)

[SQL Server] Get size of database in SQL Server 2005

Recently,

I needed to configure Liferay with SQL Server 2005 Express edition and I wanted to calculate the total database size of lportal database.

The query below gives me exact results.


Results
dbname    log_size_mb     row_size_mb      total_size_mb
lportal 1.50                   19.19               20.69

Hope this helps someone. :)

Cheers!!!

Friday, September 12, 2014

[Liferay] How to Undeploy Ext from Liferay | Undeploying ext from liferay

Recently, I had to undeploy ext plugin from Liferay

Here is what needed to be performed.

1. Delete the ext folder from webapps folder.

2. Stop the instance

3. Delete the ext service jar file from global lib. For tomcat it is in tomcat/lib
ext-*-ext-service.jar
4. Delete the ext jar files from webapps/ROOT/WEB-INF/lib
ext-*-ext-impl.jar
ext-*-ext-util-bridges.jar
ext-*-ext-util-java.jar
ext-*-ext-util-taglib.jar

5. Delete ext xml files from webapps/ROOT/WEB-INF
ext-*-ext.xml
liferay-portlet-ext.xml --will be present if any portlet was added/existing portlet was modified in a way that portlet.xml kind of changes were needed.
portlet-ext.xml --will be present if any portlet was added/existing portlet was modified in a way that portlet.xml kind of changes were needed.
tiles-defs-ext.xml

6. Delete work folder

7. Delete temp folder

8. Remove/comment any line that uses a class of ext plugin in portal-ext.properties. This can be any entry for ex. start up event, service actions etc.

So, That's it.

Cheers!!!


Friday, August 22, 2014

[Liferay] Get and Set portlet preferences in liferay | In Portlet Class and JSP

We often need to get and set preferences of a portlet. Here is few simple lines to do the job.

To get preferences of portlet, from the portlet class using actionRequest use

final PortletPreferences preferences = getPortletPreferences(actionRequest);

To get preferences of portlet, from the portlet class using renderRequest use

final PortletPreferences preferences = getPortletPreferences(renderRequest);

There are other methods as well. If we get get portletResource then to get preferences use the code below.

final String portletResource = ParamUtil.getString(portletRequest, "portletResource");

PortletPreferences preferences = null;
try {
preferences = PortletPreferencesFactoryUtil.getPortletSetup(portletRequest, portletResource);
} catch (final Exception e) {
LOG.error(e.getMessage(), e);
}

if (preferences == null) {
preferences = portletRequest.getPreferences();
}

In the JSP get the preferences using

PortletPreferences preferences = renderRequest.getPreferences();

To store preferences
preferences.setValue("key", value);
preferences.store();

Thats It! :)