Thursday, May 17, 2012

Liferay Portal Systems Development - Another Book!


Now that I got introduced to Liferay, its features and how to set it up on WebLogic Server, I wanted to learn more about the strengths of Liferay in detail. So I picked this book for my reading - Liferay Portal Systems Development. You can get an electronic copy of the book here. If you are a beginner to Liferay or you are an initial learner then you should look at my other post - Liferay Beginner's Guide.

This book is for you if you want to get serious about development with Liferay. Once you get to know the portal as user from outside the next step is to get your hands wet and dirty. This is more like opening your automobile's hood. This book explains all about the under-the-hood implementation and customization. You should be Java developer to get more benefits out of this book. But prior Liferay knowledge is not necessary.

This book clearly explains 3 different levels of development and takes you down that path.

  •  Level-I is where you will develop portlets, themes, layouts, hooks etc. At this level you are using Liferay Plugins SDK. 
  • Level-II is for advanced developers which requires you to change config files, write custom Java code, custom JSP files etc. 
  • Level-III is for more advanced developers which involves changing Liferay Portal source code. And this is the level for you if you wish to contribute to the Liferay Portal core development.
 If you want to build custom portlets, MVC portlet bridge and its extension are the gist of portlet development in Liferay. Once you build your portlet using SDK the process of deployment, configuration, using service builder to build services and models for your MVC portlet are all explained by the author in detailed steps with a sample close to realworld project in this book.

The most interesting aspect for me in this book are Hooks. Hooks are hot deployable functionalities that can let you override the portal core functionality. You can perform actions on portal startup, user login, overriding portal services, servlet filter mapping, servlet filters etc. Along with Hooks you will also learn about Ext Plugin which are used to modify the behaviour of internal out-of-the-box portlets that are distributed with Liferay to customized them for your needs. These 2 powerful features provide flexibility and customizing ability for the Liferay Portal.

One of the notorious feature of Liferay portals is the Enterprise and Web Content Management (ECM) which provides the ability to organize, store and render enterprise contents such as images, documents, organizational official business records etc. In my experience most of the organizations have their standard content management systems and would prefer to integrate their portal to existing ECMs like Documentum, Sharepoint, Alfresco etc. Author explains how to create contents, configure and use the them in Portal and integrate Liferay with exsiting ECMs. Along with the content management features the Open Social API, Social Office provides powerful social and collobartion features on top of the portal in Liferay. The books goes detail into the collaborative tools such as Wiki, blogs, message boards, polls, bookmarks etc. Also using the workflow feature of the portal and intergrating it with existing workflow engines like jBPM, Kaleo, Activiti, Intalio etc. is also well explained. Finally you can read about the mobile device detectors and WAP themes which are useful if you want your portal to be accessed by mobile devices.

Another big challange for bigger enterprise implementing any framework is how to set up the portal environment in the lower environment, test it and transition it to the production. This book explains how to setup local staging of portal and contents then publishing it to higher environments. So if you want to understand Liferay as a portal and its strengths in other areas in much more detail then this is the book you want to read. Download a sample chapter from here. Enjoy your reading!!!

Sunday, March 4, 2012

Liferay Beginner's Guide - Review

If you are trying to build more than just a simple web application and you need features like look and feel, administration, search, emailing, content management then you want a portal. There are many open source and commercial JEE portals available such as Liferay, Open portal, JBoss, Web Center Portal, Web Sphere Portal etc. Liferay is a popular light weight open source portal. "Liferay Beginner's Guide" is a good book to get started if you want to learn Liferay by yourself. You can buy an electronic or paper copy here at Packt Publishing.

You can find lot of information about using Liferay with Tomcat on the internet but very less information when it comes to commerical application servers like WebLogic Server. This book explains on how to get started with Liferay on WebLogic Server using illustrations and screen shots. I am big fan of pictures and illustrations as they can speak 1000 words :-) The previous book I read on Liferay was very developer oriented and doesn't have interesting screenshots for someone who is new. But this book explains a topic with screen shots, instructions and expalins what we just did with a summary section titled "What just happpened". I believe that is a better approach to explain hard technical concepts. "Have a go here" section will engange you to experiment with the topics more practically.

Overall this books will get anyone who is new to Liferay started with all the major concepts and help you build a site to understand the concepts. You will also build a online shopping website practically which is very interesting. More interesting topic when you build the shopping website is the integration with the Paypal sandbox environment. Publishing and content management is one of the highlight for Liferay in addition to its portal features. This book explores all the content management features of Liferay which is useful for most business scenarios. Another strengh of Liferay is the built-in portlets that comes bundled with the product and thess discussion about those built-in portlets in this book. Enterprise Edition of Lifeay is bundled with more built-in portlets and this book discussed the Community edition of the Liferay for simplicity.

One of the best topic comes as the last chapter - Administration. It is crucial for anyone who works with the product to understand little bit about the server administration. Creating multiple sites, Virtual hosting, implementing staging environments, Configuring logs, Monitoring server and portal sessiona are key topcis being discussed.

Overall, this book is a good introduction to anyone who is new to Liferay. Download a sample chapter from this book here.

Thursday, February 2, 2012

Book Review

For a change I thought of writing about my upcoming book review and Liferay Portal. I had a chance to work to Liferay Portal which is an Open Source JEE Portal. Liferay comes bundled with Tomcat but it can be deployed to run on WebLogic Server as well.

Now that I am familiar with Liferay and I am off to review this book "Liferay: Beginner's Guide". I shall share more information when I am done reading this book. For anyone who is new to Liferay, it is a light weight JEE portal. Even though it is open source there is a good support structure available from Liferay itself. There is a community edition which is free and there is a enterprise edition which is commercial. You can find more information about Liferay @ www.liferay.com.


Sunday, November 20, 2011

A good WebLogic Server Administration book after a very long time!



Recently I was involved in reviewing a book for Packt Publishing - Oracle WebLogic Server 11gR1 PS2: Administration Essentials by Michel Schildmeijer. I am not writing this post because I reviewed this book but I had a chance to read the entire content of this book. This is a book written on the topic of WebLogic Server Administration after a very long time, and a good book too. If you are someone who works on WebLogic Server & JEE technologies you would certainly know about the scarcity of books on WebLogic Server and especially administration. WebLogic Server is being used as a commodity these days for many applications and products built on JEE platforms. Even though it is widely used there aren't many books available for WebLogic Server and the documentation serves as a good reference. But with the growing features on WebLogic Server in the past few years it is hard to learn for any new comers or who are non-developers if you are not following the product for a few years. This book comes as huge gap filler on this area.

The flow of this book would prepare you from planning to production and tuning with a good story line. As WebLogic Server is being used as the application server for almost all the Oracle Fusion Middleware Suite of products Michel not only talks in the perspective of simple JEE applications but also talks about how WebLogic fits in the Fusion Middleware area which is a key benefits that you can ripe from this book. As WebLogic is rich in features especially the administration console, I expected a bunch of screen shots and less narration when I first started reading this book for review. But Michel really balanced between the content and the screenshots, which are presented wherever it is necessary. When I used to go around training customers for BEA and Oracle in WebLogic Server, I was always in need of a white board rather than prepared presentation contents. You can clearly see that need from this book which has many diagrams hand-drawn (Of course using some tool) to explain a lot of topics.

It would say the power of this book is the take off low and fly high approach to many topics, cohesive order of the topics presented to the viewers, compilation of real world experiences and best practices.

This is a good reading if you are a Oracle WebLogic Administrator or any Oracle Fusion Middleware product administrator or trying to become one. So if you are looking to learn or reinforce your knowledge in WebLogic Server this is a good book. And this is available both in printed and electronic format.

Thursday, February 17, 2011

IDE for WLST Scripting - OEPE

In the past many folks asked me about a GUI based tooling support for WLST. Some people managed to use some Jython tools for WLST but it is not straight forward and supported by Oralce. What you need to author WLST scripts more efficiently is a tooling support to develop WLST Scripts. If you are involved in writing a lot of WLST scripts then you will appreciate this initiative.

Oracle just came up with a OEPE (Oracle Enterprise Pack for Eclipse) based tooling for WLST. Some of the features of this tool are:

* WLST/Jython/Python Source Editor
* Syntax highlighting, validation
* Code completion
* WLST Templates
* MBean Navigator for browsing MBeans
* WLST Execution and Console in Eclipse
* WLST integrated Help
* Support for both online and offline modes

Currently anyone who is authoring WLST scripts must refer to the docs for syntax and samples. This will be a good tool for developers so that they can build WLST Scripts within a comfortable environment - Eclipse/OEPE. Also administrators can benefit from the this tool as there are features like templates, code completion etc. The latest release of OEPE 11gR1 (11.1.1.6) comes with this tooling. To find more about the new features of this release see here.

5-Part WLST Best Practices Series

A while ago I wrote a 5-part WLST Best Practices series . Here I am consolidating this post with link to all those 5 posts.

Tuesday, August 3, 2010

Configure Email Notification in WebLogic Server

Introduction

If you are administering applications deployed on WebLogic Server or if you are operations personal responsible to manage a WebLogic Server environment you might have at least asked the following question once:

“Can I setup WebLogic Server to send automatic notifications?”

People always ask me whether WebLogic Server can send automatic notifications. My answer is - "Yes, WebLogic Server had always supported SNMP which can be configured to do standard SNMP Trap notifications to your enterprise monitoring system which can then be sent as an email or pager out to administrators". But the next question is - "I don't want to set up SNMP and I want WebLogic Server to directly send notifications. Can we do that?" Again the answer is - "Yes, starting from version 9.x WebLogic Server supports a new framework called WebLogic Diagnostic Framework - WLDF, which can be used for this purpose". Enterprise monitoring solutions like Oracle Enterprise Manager, HP Open View can monitor WebLogic Server from outside and can trigger notification among various other management and monitoring features. But you can also set up WebLogic Server to directly send many types of notifications. Let us see how to simply set up an email notification with WLS in this article.

Oracle WebLogic Server is Java EE certified application server which is the foundation of many Service Oriented Architecture (SOA) implementations. So many enterprises have their mission-critical applications deployed on WebLogic Server. WebLogic provides a scalable and highly available environment. If you are deploying your mission critical applications on Oracle WebLogic Server you can make use of WebLogic Diagnostic Framework (WLDF) to get diagnostic data from WebLogic Server instances and from applications deployed to them. This will help administrator and system operators to see more information from under the hoods.

This powerful feature will play a significant role in production environment where the application environment should alert operational personal when there is a performance or service level violation. This also eliminates the need to setup custom or third-party monitoring solutions for alerting and notification.

WebLogic Diagnostics Framework – Watch & Notification

One of the features of WLDF is Watch and Notification. You can configure server(s) with watch condition and respective notification(s) to be sent if the watch conditions are met. For example, if the number of request waiting on a JDBC Data Source to grab a connection exceeds 10 and if the free heap in the server is less than 5% then you can trigger a notification. The notification can be one or more of the following types:

  • JMX Notification - Application(s) can register notification listener with WLDF to receive notifications.
  • JMS Notification - WLDF can post a message to JMS destination to alert the situation which can be consumed by a message listener or MDBs to further processing.
  • SNMP Notification - SNMP traps can be sent to alert SNMP managers.
  • SMTP Notification - Email notifications through a Java Mail session.
  • Image Notification - Generates a server image which contains information from different subsystem during the watch.

Figure: 1 WebLogic Domain


You can configure Watch conditions on the MBean data, Log messages and WLDF Event data. The notification can be one or more of the above notifications. Since email notification is a common request, I shall illustrate how to setup WLS to send email notification using an open source SMTP server - The Apache Java Enterprise Mail Server (Apache James). To download Apache James, go to - http://james.apache.org/server/ [or] http://people.apache.org/dist/james/server/binaries/. Download and extract the zip file to a convenient location (Eg. /usr/james-2.3.1rcl/). Start the server using run.sh from the bin folder under the JAMES_HOME. Setup a test user in James as per these instructions - http://james.apache.org/server/2.3.1/adding_users.html. The default admin username and password for James are root/root.

Ensure that the James mail server and the administration server for the domain are started. If not, use DOMAIN_HOME/startWebLogic.cmd/sh for starting the administration server of your domain and use JAMES_HOME/bin/run.bat/sh to start James Server. You can use console or WLST to configure the following setting. Let us use the web-based administration console for configuration. Log in to WebLogic Administration Console at - http://localhost:7001/console using an administrative account.

Creating JavaMail Session

First step is to make sure that the underlying resources for the notification are setup. In this case we are going to use SMTP notification so let us first create the Java Mail Session to connect to James Mail Server.

  1. Click "Lock & Edit" to acquire a configuration lock
  2. Expand Services > Mail Sessions and click "New" to create a new Java Mail Session.
  3. Provide Name, JNDI Name and JavaMail Properties as follow:
  4. Name - James-MailSession
  5. JNDI Name - com.test.myjamesMailSession
  6. JavaMail Properties:

mail.transport.protocol=smtp

mail.smtp.host=localhost

mail.smtp.user=admin

mail.smpt.password=password

  1. Click next to target the mail session to a server (Eg. AdminServer or mgd_s1) and click finish.
  2. Activate the changes by clicking "Activate Changes".


Figure: 2 Configuring JavaMail Session


If you are using a different mail server use appropriate information.

Creating WLDF Module

Next step in configuring watch and notification is to create a diagnostic module and target it to the server. You can use console or WLST to create a diagnostic module. The following steps illustrate the steps to create a WLDF system module:

  1. Click "Lock & Edit" to acquire a configuration lock
  2. Click Diagnostics > Diagnostics Modules and click "New" to create a new diagnostics module. Provide a name and description.
  3. Name - Test_WLDF_Module
  4. Description - This is a WLDF module for testing email notifications

  1. Select the newly created module and select targets tab. Select the appropriate server for target as before
  2. Click "Save" and "Activate"



Figure: 3 Configuring Diagnostic Module

Creating Watch & Notification

Each WebLogic Server instance can be configured with only one diagnostic module but you can target the same diagnostic module to multiple servers or clusters. Once the WLDF system module is created and targeted to the appropriate server then watches and notifications can be configured. The following steps illustrate how to create a Watch and a Notification.

To create a watch:

  1. Click "Lock & Edit" to acquire a configuration lock
  2. Navigate to the diagnostic module created above (Test_WLDF_Module) and select the "Watches and Notifications" tab and "Watches" sub-tab (if not already selected)
  3. Click "New" to create a new Watch. Provide the name and select the type as "Collected Metrics" [Select "Collected Metrics" for inspecting Runtime MBean values, "Server Log" to watch log data and "Event Data" to watch instrumented data]
  4. Name - Heap_Watch
  5. Watch Type - Collected Metrics
  6. Enable Watch - Selected
  7. Click "Next"
  8. Click "Add Expressions"
  9. Ensure that "ServerRuntime" is selected and click "Next"
  10. If you are running WebLogic Server on Java HotSpot VM, make sure "Select an MBean Type from the following list" is selected and select "weblogic.management.runtime.JVMRuntimeMBean" and click "Next". If you are using JRockit VM, make sure "Select an MBean Type from the following list" is selected and select "weblogic.management.runtime. JRockitRuntimeMBean" and click "Next".
  11. Select the instance for the appropriate server from the list for "Instance" and click "Next"
  12. For "Message Attribute" select "HeapFreePercent", "<" for "Operator" and type "85" for "Value". Click "Finish" twice to create a Watch
  13. Activate the changes



Figure: 4-a Configuring Watch



Figure: 4-b Configuring Watch


The above watch will trigger the configured notification if the percentage of free heap is less than 90. You could make complex rule expression by combining multiple attributes from different MBean. For now we haven't configured any notification for this watch. We will create the notification and will associate it to the watch in the following steps.

To create a notification:

  1. Click "Lock & Edit" to acquire a configuration lock
  2. Navigate to the diagnostic module created above and select the "Watches and Notifications" tab and "Notification" sub-tab
  3. Click "New" to create a new Notification
  4. Select "SMTP (E-Mail) for Type and click "Next"
  5. Provide a name - James_Email_Notification. Make sure the notification is enabled and click "Next".
  6. Configure the following properties for the "Config Notification - SMTP Properties" page
  7. Mail Session Name - James-MailSession
  8. E-Mail Recipients - admin@localhost

  1. Click "Finish".
  2. Activate the changes


Figure: 5-a Configuring SMTP Notification


Figure: 5-b Configuring SMTP Notification


To associate the watch and the notification:

  1. Click "Lock & Edit" to acquire a configuration lock
  2. Navigate to the diagnostic module created above (Test_WLDF_Module) and select the "Watches and Notifications" tab and "Watches" sub-tab (if not already selected)
  3. Select the watch you created earlier - Heap_Watch
  4. Select the "Notifications" tab and move the "James_Email_Notification" from Available to Chosen
  5. Click "Save"
  6. Select the "Alarms" tab and select "Use an automatic reset alarm". Set the "Automatic reset period" to 6 and click "Save". This will ensure that the notifications are at least 90 seconds apart.
  7. 5. Click "Activate Changes"

Figure: 6-a Associating Watch and Notification

Figure: 6-b Configuring Alarm

As we configured the watch type to be Collected Metrics, the attributes involved in the watch rule will be harvested and tested for watch rule expression(s). The default sampling period for the harvester is 300,000 milliseconds (or 5 minutes). So the time between samples will be 5 minutes. To change the sampling period for metrics collection:

  1. Click "Lock & Edit" to acquire a configuration lock
  2. Navigate to the diagnostic module created above (Test_WLDF_Module) and select the "Collected Metrics" tab
  3. Ensure that "Enabled' check-box is selected
  4. Change the "Sampling Period" as "120000" so that it will collect samples once every two minute


Figure: 7 Configuring Sampling Period


To receive the notifications sent by WebLogic Server as emails, install and configure an email client like Mozilla Thunderbird. The following is an example of the email received from WebLogic Server:

Using WLST

The configurations that are illustrated using Administration Console here can also be done using WLST. The following script is an example WLST script to configure a Javamail session, WLDF Module, Watch and Notification:




#Connect to the admin sever
connect('weblogic','Welcome1','t3://localhost:7001')

#Start a change session
edit()
startEdit()
cd('/')

#Create and configure a Javamail session
cmo.createMailSession('James-MailSession')
cd('/MailSessions/James-MailSession')
cmo.setJNDIName('com.test.myjamesMailSession')
cmo.setProperties({mail.smtp.user=user;, mail.smpt.password=password;, mail.smtp.host=localhost;, mail.transport.protocol=smtp;})
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

#Create and configure a WLDF Module
cd('/')
cmo.createWLDFSystemResource('Test_WLDF_Module')
cd('/SystemResources/Test_WLDF_Module')
cmo.setDescription('This is a WLDF module for testing email notifications.')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

#Create and configure a WLDF Watch
cd('/WLDFSystemResources/Test_WLDF_Module/WLDFResource/Test_WLDF_Module/WatchNotification/Test_WLDF_Module')
cmo.createWatch('Heap_Watch')
cd('/WLDFSystemResources/Test_WLDF_Module/WLDFResource/Test_WLDF_Module/WatchNotification/Test_WLDF_Module/Watches/Heap_Watch')
cmo.setRuleType('Harvester')
cmo.setEnabled(true)
#For HotSpot VM
#cmo.setRuleExpression('(${ServerRuntime//[weblogic.management.runtime.JVMRuntimeMBean]com.bea:Name=AdminServer,ServerRuntime=AdminServer,Type=JVMRuntime//HeapFreePercent} < 85)')
#For JRockit VM
cmo.setRuleExpression('(${ServerRuntime//[weblogic.management.runtime.JRockitRuntimeMBean]com.bea:Name=AdminServer,ServerRuntime=AdminServer,Type=JRockitRuntimeMBean//HeapFreePercent} < 85)')
cmo.setAlarmType(None)

#Create and configure a WLDF SMTP Notification
cd('/WLDFSystemResources/Test_WLDF_Module/WLDFResource/Test_WLDF_Module/WatchNotification/Test_WLDF_Module')
cmo.createSMTPNotification('James_Email_Notification')
cd('/WLDFSystemResources/Test_WLDF_Module/WLDFResource/Test_WLDF_Module/WatchNotification/Test_WLDF_Module/SMTPNotifications/James_Email_Notification')
cmo.setEnabled(true)
cmo.setMailSessionJNDIName('com.test.myjamesMailSession')
set('Recipients',jarray.array([String('admin@localhost')], String))
cmo.setSubject(None)
cmo.setBody(None)

#Associate the watch and notification
cd('/WLDFSystemResources/Test_WLDF_Module/WLDFResource/Test_WLDF_Module/WatchNotification/Test_WLDF_Module/Watches/Heap_Watch')
set('Notifications',jarray.array([ObjectName('com.bea:Name=James_Email_Notification,Type=weblogic.diagnostics.descriptor.WLDFSMTPNotificationBean,Parent=[testdomain]/WLDFSystemResources[Test_WLDF_Module],Path=WLDFResource[Test_WLDF_Module]/WatchNotification[Test_WLDF_Module]/SMTPNotifications[James_Email_Notification]')], ObjectName))
cmo.setAlarmType('AutomaticReset')
cmo.setAlarmResetPeriod(60000)

#Set the sampling period
cd('/WLDFSystemResources/Test_WLDF_Module/WLDFResource/Test_WLDF_Module/Harvester/Test_WLDF_Module')
cmo.setSamplePeriod(120000)
cmo.setEnabled(true)

#Activate the changes
save()
activate()

#Exit
exit()