Friday, November 28, 2014

Liferay Plugin Applications Deployment Process Details


We have different kind of liferay applications such as plugins and exts.
Coming to plugins we have portlets,hooks,themes,layouts and webs.

Install/Deploy Liferay Applications.


Web Applications Deployment

Deployment is a process in web application to place application archive files(WAR, EAR) in application server deployment directory and start the the application.

Deployment directory is place in application server there all the web application are reside and running from there.

Based on application server the deployment directory may be change, lets say in Tomcat Server deployment directory is “webapps” (tomcat-7.0.42/webapps). Jboss “deployments” (jboss-7.1.1/standalone/deployments) is deployment directory.

Applications Archive Files

Generally in web application development we will package all artifacts such as files, Java classes, configuration files, properties file,deployment descriptors and requires libraries and its directories as archive files.

In J2EE development of web application we can see two kinds of Archive Files such as EAR(Enterprise Archive Files) and WAR (Web Archive Files).

EAR(Enterprise Archive Files) are related Enterprise Java Beans Technology based packaging and its required EJB containers to run those applications.

WAR (Web Archive Files) are related to J2EE based Technology web application packaging and it also required respective containers to run the applications.

.WAR file:

After package the web application artifact in single archive and these files extension always be .war(HelloWorld.war,Sample.war)

Generally Application Server recognize the .war extension file so that it will process required steps to run the application.

Note:

Based on server properties web archive files(.war) file will be unpackaged/exploded once it placed in server deployment directories.

To run any J2EE web applications they need respective technology based containers to provide run time environment to the applications.

Generally when we deploy web applications we need to stop server and restart the server to see the changes in the application.

Assume we are deploy the applications in production servers so its not good to down/stop servers. This is where we have a concept called “Hot Deployment”.

Hot Deployment:

Hot Deployment is one of the web applications deployment process where we don't need to stop servers while deployment of web applications and it will start the applications and we can see changes at run time.

In the process of Hot Deployment there is specialized directory to place web archive files instead of directly placing into server deployment directory.

Assume we have web application we want deploy into different application servers and each application deployment process is different and we may need to add some other configuration or supported libraries to make successful deployment. This is typical task to deploy in different servers, to make this work easy we have process called “Auto Deployment”

Auto Deployment

Auto deployment is one web application deployment process there we can deploy web application into different application server and required server dependent configuration and libraries will be added automatically to make successful deployment of application.

Liferay Deployment Details

Liferay also support two deployment capabilities such as Hot Deployment and Auto Deployment.

Liferay Hot Deployment:

Hot Deployment process we can see in the J2EE severs environment and we will place the application archive files(WAR,EAR) files in specially configured directory and application server (Tomcat, WebSphere, WebLogic, etc.) picks up that artifact, deploys it within the application server, and starts the application

We already know liferay is also web application and its also packaged as
.war file.
To support “Hot Deployment” Liferay Server Bundle have one directory called “deploy” directory.

Deploy” directory will be in “Liferay Home” directory. We will deploy liferay archive files in “deploy” directory and as soon as we placed web archive file in deploy directory then Hot Deployment scanner pick the file and placed in server deployment directory in addition to this it will add required configuration to the application.

Hot deployment is good for development environment and deploy liferay applications in single server production environment and in this mode we need not restart server.

Liferay Hot Deployment have limitation it wont work in multi-node production deployment and we have many constraints to deployment liferay applications in multi node server environment.

When we work with Multi Node/Multi Server production Environment we should make sure following things

Web Application Archive File should be available to all servers
Application should deploy successfully in all servers simultaneously

In the multi server production environment we need design deployment architecture so that it will complete deployment in all servers successfully.

Generally we will use Admin Servers it will take to deploy application in all remaining serves successfully and simultaneously this is called master and slave architecture.

Application server provide different tools or admin console to do hot deployment job in all servers.

JBoss “domain” mode

WebLogic “production” mode

WebSphere deployment manager

Tomcat FarmWarDeployer

These modes and tools reside completely outside of Liferay Portal and are strictly in the application server’s realm. However, Liferay piggybacks off the application server’s hot deploy capability and performs additional initialization after a given application starts (e.g., via javax.servlet.ServletContextListener mechanisms).

We have different types of liferay plugin applications and all plugins have hot deployment capabilities. If we deploy any liferay Plugin applications such as portlet, hook,theme,layout and web then we need not start server and the change will be applied.

There are some specific Liferay capabilities that won’t work unless your application server has hot deployment capabilities. Specifically, hot deploying custom JSPs in hooks won’t work, because Liferay’s JSP hook overriding capabilities depend on the application server’s ability to: 

Deploy based on an exploded portal WAR
Load changes to JSP files at runtime

Generally when we deploy web archive(.war) files in servers these web archive files are unpackaged/exploded in the server deployment directory in the process successful deployment this kind of behavior we will use mostly in local development environment.

In the production/domain environment don’t use unpackaged/exploded WARs because of these some of liferay hooks not support hot deployment capabilities such as Custom JSP hook. Production servers don’t support JSP reloading/recompilation in these modes. Even for Tomcat, it’s generally advisable to deactivate JSP reloading for production deployments.

So what do you do if you use hooks to override Liferay JSPs AND you must use non-exploded WAR deployments? The answer is simple: inject a pre-processing stage as part of your build process. You deploy the hooks, allowing them to make changes to the portal WAR file. Then you re bundle the portal WAR file and deploy it using the application server’s deployment tools. Of course, you still need to deploy your hook as well, but you no longer need to worry about the JSP overrides not being loaded by your application server.

Liferay Auto Deployment:

Liferay Auto deployment process is similar to hot deployment and its injecting required jar files and deployment descriptors into web application archive file at time of deployment. Liferay auto deployment also have capabilities of hot deployment capabilities. Executing ant deploy invokes both hot deployment and auto deployment tasks for your plugin.

In the process of Auto Deployment the followings task will be takes place.

Picks up a Liferay recognized archive (e.g., *-portlet.*, *-theme.*, *-web.*, *.lpkg)

Injects required libraries (e.g., util-java.jar, util-taglib.jar)

Injects dependent JAR files (specified in liferay-plugins.properties)

Injects required taglib descriptors (e.g., liferay-theme.tld)

Injects required deployment descriptors (e.g., app server specific descriptors)

Injects any missing Liferay specific deployment descriptors (e.g., liferay-portlet.xml)

Auto deployment helps us to successful deployment in different server environment because it will automatically add server depended deployment descriptors at time of deployment.

Liferay Auto deployment also not compatible in the multi-node production environments Do not use the auto deployment method at runtime; use it at build time.

Generally when we use ant deploy then it will invoke auto deployment tasks and we have another ant target ant direct-deploy and The direct-deploy Ant task creates an exploded WAR from which you can easily create a WAR file. The location of the exploded WAR depends on the deployment directory of the application server you’ve configured in your Plugins SDK environment

ant direct-deploy create war file and inject all required jar files and server dependent deployment descriptors then it will directly placed war file in application server deployment directory and server deployment directory information configure in build.properties file.

The Plugins SDK’s build.properties provides a default deployment directory value for each supported app server. But you can override the default value by specifying your desired value for the app.server.[type].deploy.dir (replace [type] with your app server type) in your build.[username].properties file.


Example:

app.server.tomcat.deploy.dir = /opt/LiferayWorkSpace62/bundles/tomcat-7.0.42/webapps

Important Points

Liferay Plugin applications support hot deployment capabilities so we need not to start application server while deployment and changes will be applied directly.

Liferay Plugin Applications are packaged as web archive files that is .war file and liferay application also packages as .lpkg When we download any application from liferay market place we can see portlet application extension as .lpkg and internally .lpkg contains one or more .war files.

When you want deploy external liferay application such as .war or .lpkg then we simply place these files in liferay “deploy” directory and this is available in “Liferay Home” or we can change these directory path with the property auto.deploy.dir = ${app.server.parent.dir}/deploy this property in build.properties file of your Plugins SDK and you can override this property in build.[username].properties file

Liferay hot deployment should be supported by application server then only liferay applications can inherited those capabilities.

Liferay Hot deployment can be successfully work in development environment and single node production environment and these capabilities are not compatible in multi node server environments.

All applications build related properties are available in Plugins SDK build.properties files there you can choose server environment and other environment related properties and we can also override these properties in build.[username].properties file.

Liferay Auto deployment process will take caring packaging application, inject required jar filed and server supported deployment descriptors and then deploy into application servers.

Liferay Auto deployment is also successfully work in development and single node production environment and its not compatible in multi-node production server environment.

Each Liferay Plugin Application have different ant task such as ant deploy and ant direct-deploy. When we run ant deploy then it will invoke auto deploy and hot deploy tasks.

ant deploy” target perform tasks such as package as web archive file,inject required jar files then place the war file in liferay “deploy” directory. As soon as application war file placed in deploy directory then hot deployment scanner will perform necessary steps to complete the application deployment success.

ant direct-deploy” target perform tasks such as package as web archive file,inject required jar files and inject server dependent deployment descriptors then place the WAR file in server deployment directory.

Liferay development in development environment and single node production environment is pretty straight forward way but when we work with production environment and multi-node server environment we need to put some additional effort to complete successful deployments.

Author

1 comment :

  1. I think, this plugin make more easy for developer to complete the work. Moreover, I am providing the Impact Window Replacement Services in Deerfield Beach FL and give you reliable service.

    ReplyDelete

Recent Posts

Recent Posts Widget

Popular Posts