Liferay Environment Challenges and Solutions with Eclipse

Liferay Environment Challenges and Solutions with Eclipse
  • ECJ is not installed Error when deploy the portlet from eclipse
  • PermGen Space Error / Out of Memory Error


ECJ is not installed Error when deploy portlet in eclipse



Solution: 1

Generally in liferay to compile and build the application it uses ECJ jar. When we use following properties in build.properits file of Liferay Plugins SDK


#javac.compiler=modern
   javac.compiler=org.eclipse.jdt.core.JDTCompilerAdapter


When we use JDT compiler in eclipse then It will expect ecj.jar should be available in global ant runtime path.

So we need to add ecj.jar file to ANT global class path as follows

Go to eclipse windows preferences


Select ANT run time as follows




Now add jar file to ant global class path. Select external jar file button then brows ecj.jar file

Note:

ecj.jarfile available in Plugins SDK lib directory (liferay-plugins-sdk-6.2.0/lib)




Solution: 2

Now we can also skip this error by using java compiler to modern.

We already know we have created SystemUserName.build.properties to override properties in Plugins SDK build.properties file.

We just uncomment JDT compiler and enable java complier to modern in SystemUserName.build.propertisfile of your Plugins SDK.

Do as follows in properties file

    javac.compiler=modern
   #javac.compiler=org.eclipse.jdt.core.JDTCompilerAdapter


PermGen Space Error / Out of Memory Error

When we run liferay we need to set heap memory for JVM that is used by liferay application server

The following three options witch control the JVM Heap memory so that we need to set this values as JAVA_OPTS.


-Xms
-Xmx
-XX:MaxPermSize


Set this following values as JAVA_OPTS so that liferay portal can run without PermGenspace error or Out of Memory Error


-Xms1024m -Xmx1024m -XX:MaxPermSize=256m


We can set JAVA_OPTS in following ways

  1. Set JAVA_OPTS as System Variable
  2. Set JAVA_OPTS in Application Server
  3. Set JAVA_OPTS to Eclipse Configured Server


Set JAVA_OPTS as System Variable in Windows

When we set JAVA_OPTS as System Environment Variable then all servers uses the same java opts to all servers and applications which are running in the machine

To set JAVA_OPTS in windows operating system we need to go to computer properties and need to choose Advanced System Settings

The following screen shows to select computer properties




Now click on Environment variables

The following screen shows advances system settings



In the system variables section click on new button to create new system environment variables

The following screen shows create system environment variables




Once click on new it will ask variable name and its value and click on OK then JAVA_OPTS will be created as System Environment Variables.

Enter following values

Variable Name:  JAVA_OPTS
Variable Value:  -Xms1024m -Xmx1024m -XX:MaxPermSize=256m




Note:

When we set JAVA_OPTS as system variables then all application servers which are running in the machine will use these values.

This variable not only for Liferay portal it can be for any web applications which are running in the server.

This variables setting in windows environment and its same for other OS like Linux but setting of variable is bit different.

Set JAVA_OPTS in Application Server

We can also set JAVA_OPTS values in application serves. For each server there some configuration files we can set server configuration in the file so that it can be read by when server is starting.

When we set the value in server then it can be used by application which is running in the server.
Server configuration file is different with respect to server vendor.

Tomcat Server:

In tomcat we will use setenv.bat/setenv.sh file to configure JAVA_OPTS
Go to tomcat server bin directory and create setenv.bat file for windows environment and setenv.sh for Linux environment.


Once we create the files add JAVA_OPTS in file as follows

In windows setenv.bat as follows

set "JAVA_OPTS=%JAVA_OPTS% -Xmx1024m -XX:MaxPermSize=256m"

In Linux setenv.sh as follows

export JAVA_OPTS="$JAVA_OPTS -Xmx1024m -XX:MaxPermSize=256m"

In tomcat server we can also use CATALINA_OPTS instead of JAVA_OPTS. This is only for tomcat server

In windows setenv.batas follows

set " CATALINA_OPTS =% CATALINA_OPTS % -Xmx1024m -XX:MaxPermSize=256m"

In Linux setenv.shas follows

export CATALINA_OPTS ="$ CATALINA_OPTS -Xmx1024m -XX:MaxPermSize=256m"

Note:

In liferay tomcat server setenv.bat/setenv.sh and configuration already have done. If any problem occurred we just need adjust the values in configuration.

This configuration not only for liferay environment we can use for any web applications which are in running in server.

JBOSS Server

Jboss in windows

Jboss server in windows OS we will use standalone.conf.batthis file available in jboss server bin directory (jboss-7.1.1\bin).





Open jboss standalone.conf.bat and set JAVA_OPTS as follows


set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"



Jboss in Linux

Jboss server in Linux we will use standalone.confthis file available in jboss server bin directory(jboss-7.1.1\bin).




Open jboss standalone.conf and set JAVA_OPTS as follows


JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"


Note:

In liferay jboss bundle all configurations already done and when we get any problems then we just need to adjust values.

These configuration can use for any web application not only for liferay.


Set JAVA_OPTS to Eclipse Configured Server

Generally we configure application servers to eclipse. We can also configure the values through eclipse.

In ellipse go to servers view and double click on server and then click open launch configuration



Once opened configuration winnow select arguments tab and see the VM arguments
Now you can see memory related variables and you can adjust the size of variables



 Related Articles:

http://www.liferaysavvy.com/2012/09/setting-environment-variables-and.html

Author

Meera Prince
Share on Google Plus

About Meera Prince

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment