Thoughts and Tutorials about Continuous Integration, Application Integration, SOA, IT Architecture, WebSphere and Liferay

Jul 17, 2008

Install and start an application using wsadmin

Copy the application ear-file to <WAS_PROFILE_ROOT>/installableApps

1. Open wsadmin (with jython)
1.1 Go to "WebSphere_Profile_Root"/bin
1.2 Execute
wsadmin.sh(.bat) -lang jython
1.3 Enter UserID/Password (if promted)

2. Define needed cell and node variables
2. Execute
cell=AdminConfig.list('Cell')
cellname=AdminConfig.showAttribute(cell,'name')
nodes=AdminConfig.list('Node',cell)
nodename=AdminConfig.showAttribute(nodes,'name')
-----------------------------------
(Alternative:
e.g.: nodename=NAME_OF_NODE)


3. Install application
3.1 Execute
AdminApp.install('../installableApps/<NAME_OF_EAR_FILE>',['-appname <NAME_OF_APPLICATION>'])

4. Save changes
4.1 Execute
AdminConfig.save()

5. Define application manager variable
5.1 Execute
appManager=AdminControl.queryNames
('type=ApplicationManager,cell='+cellname+',
node='+nodename+',process=,*')
5.2 To print out variable execute
print appManager

6. Assign application to variable
6.1 Execute
app=AdminControl.queryNames
('type=Application,cell='+cellname+',node='+nodename+',
process=,J2EEName=,*')
6.2 To print out variable execute
print app

7. Define application name to variable
7.1 Execute
appName=AdminControl.getAttributes(app,'name')
7.2 To print out variable execute
print appName

8. Start application
8.1 Execute
AdminControl.invoke(appManager, 'startApplication',appName)


Hint:
It is easier to use administrative console :-)

<APP_SERVER_NAME>= Name of server (JVM) where the application is deployed
<NAME_OF_APPLICATION> = Name of the application (not the ear-files name)

Links:
Install applications [IBM]
Start applications [IBM]

Stop and uninstall an application using wsadmin

Before the application can be unsinstalled it must be stopped.
Steps:

1. Open wsadmin (with jython)
1.1 Go to "WebSphere_Profile_Root"/bin
1.2 Execute
wsadmin.sh(.bat) -lang jython
1.3 Enter UserID/Password (if promted)

2. Define needed cell and node variables
2. Execute
cell=AdminConfig.list('Cell')
cellname=AdminConfig.showAttribute(cell,'name')
nodes=AdminConfig.list('Node',cell)
nodename=AdminConfig.showAttribute(nodes,'name')
-----------------------------------
(Alternative:
e.g.: nodename=NAME_OF_NODE)

3. Define application manager variable
3.1 Execut
appManager=AdminControl.queryNames
('type=ApplicationManager,cell='+cellname+',
node='+nodename+',process=<APP_SERVER_NAME>,*')
3.2 To print out variable execute
print appManager

4. Assign application to variable
4.1 Execute
app=AdminControl.queryNames
('type=Application,cell='+cellname+',node='+nodename+',
process=<APP_SERVER_NAME>,J2EEName=<NAME_OF_APPLICATION>,*')
4.2 To print out variable execute
print app

5. Define application name to variable
5.1 Execute
appName=AdminControl.getAttributes(app,'name')
5.2 To print out variable execute
print appName

6. Stop application
6.1 Execute
AdminControl.invoke(appManager,'stopApplication', appName)

7. Uninstall application
7.1 Execute
AdminApp.uninstall(appName)

8. Save changes
8.1 Execute
AdminConfig.save()


Hint:
It is easier to use administrative console :-)

<APP_SERVER_NAME> = Name of server (JVM) where the application is deployed
<NAME_OF_APPLICATION> = Name of the application (not the ear-files name)
Links:
Stop Application [IBM]
Uninstall Application [IBM]

Jul 16, 2008

Setting up an external environment for Liferay 5.0.1 [Windows]

To setup an ext-environment (or: development environment) for Liferay 5 you will need following files:
Ant
Jikes
Java JDK (1.5 and 1.6 will work)
Liferay 5.0.1 source
Liferay 5.0.1 Tomcat-Bundle

First you need to install/unpack Apache Ant, Jikes and the Java JDK.
Also you need to set the system variables ANT_HOME, JIKES_HOME, JAVA_HOME to the correct folders.
1. Create following folder for the external enviroment
1.1 ROOT (c:/ext)
1.2 EXT (c:/ext/portal)
1.3 SRC (c:/ext/src)
1.4 TOMCAT (c:/ext/tomcat)
2. Unpack the downloaded Liferay files
2.1 Unpack Liferay 5.0.1 source to SRC
2.2 Unpack Liferay 5.0.1 Tomcat-Bundle to TOMCAT

3. Create release property file
3.1 Go to SRC and create a file called
release."WINDOWS_USER_NAME".properties
(e.g: release.Administrator.properties)
3.2 Open file and enter
lp.ext.dir=EXT
(e.g: lp.ext.dir=c:/ext/portal)

4. Run ant compile to create files for EXT
4.1 Open command promt and go to SRC
4.2 Execute
ant clean start build-ext
4.3 The compiled files will be moved to EXT


5. Create appserver property file
5.1 Go to EXT and create a file called
app.server."WINDOWS_USER_NAME".properties
(e.g: app.server..Administrator.properties)
5.2 Open file and enter
app.server.type=tomcat
app.server.tomcat.dir=TOMCAT
(e.g: app.server.tomcat.dir=c:/ext/tomcat)

6. Run ant deploy to deploy files in Tomcat
6.1 Open command promt and go to EXT
6.2 Execute
ant clean deploy
6.3 The deployed files will be moved to TOMCAT/"LIFERAY_ROOT"


Optional:
Create Eclipse projects for external enviroment
1. Open Eclipse (workspace: ROOT)
2. Create new java project called src from existing project (path: SRC)
3. Create new java project called portal from existing project (path: EXT)
4. Open Ant-View (Window > Show View > Ant)
5. Drag & Drop build.xml from src-project into the ant view (on the right)
6. Drag & Drop build.xml from portal-project into the ant view (on the right)

Very useful link:
Liferay Wiki

Jul 15, 2008

Show all JNDI-entries

Sometimes you need to get all entries in the JNDI-namespace (JNDI=Java Naming and Directory Interface). In order to do this you can use the script dumpNameSpace.sh (.bat).
Just execute dumpNameSpace.sh
The script is located in the bin-folder of the profile-root.

/"WebSphere_Profile_Root"/bin/dumpNameSpace.sh(.bat)

Its possible to limit the output to a cell or a node. All avaiable parameters can be viewen here.

Jul 9, 2008

Add a portlet to Liferay (deployed via WebSphere's admin console)

Also see this post

In this post i try to descripe how to deploy a portlet in liferay's portlet container using the administrative console of a WAS 6.1 installation.
I will use the sample-jsp-portlet for demonstration.
Steps:
1. Stop Liferay / Server
2. Copy portal-kernel.jar to "WebSphere_System_Root"/lib/ext/
3. Restart Liferay / Server
4. Edit the web.xml of your portlet-war-file.
4.1. Add following entries (for sample-jsp-portlet):


<web-app>
<display-name>sample-jsp-portlet</display-name>
<listener>
<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
</listener>
<context-param>
<param-name>com.ibm.websphere.portletcontainer.PortletDeploymentEnabled</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>sample_jsp_portlet</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
<init-param>
<param-name>portlet-class</param-name>
<param-value>com.liferay.sample.jsp.portlet.JSPPortlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sample_jsp_portlet</servlet-name>
<url-pattern>/sample_jsp_portlet/*</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
</taglib>
</web-app>
Link to complete Web.xml for sample-jsp-portlet


Hint: Use Winrar to edit the web.xml in the war-file.
4.2 Edit the portlet.xml
4.2.1 Edit portletName-Tag to
<portlet-name>sample_jsp_portlet</portlet-name>

5. Deploy the portlet via administrative console of WebSphere.
5.1 Go to Enterprise applications > "Select your Liferay application" > Click "Update" > Select " Replace or add a single module"
5.2. Browse to the edited portlet-war-file.
5.3 Set "Specify the path beginning with the installed application archive file to the module to be replaced or added." to the portlet's name (in this case: sample-jsp-portlet).
5.3 Set the context path to a correct value (in this case i used: sample-jsp-portlet).



5.4. Click "Next" to start the deployment dialogs
5.5. Click through all deployment steps (change context path to "sample-jsp-portlet" (Step 7)).
5.6. Click "Finish" to deploy the portlet.
6. The portlet will be installed to the liferay-folder and can be added via the "Add application"-menu in Liferay (perhaps you have to restart Liferay/the server).

Download the complete sample-jsp-portlet for websphere here.


Special thanks to "Mate".
Links:
Liferay Forum Posts
IBM PK34915

Jul 4, 2008

Add an additional language to Liferay

Adding an additional language to Liferay is not so difficult as it sounds.
For demonstration i will add the "language" en_GB (English for Great Britain)
to Liferay (5).

All supported locales can be viewed here (Java EE - Standard!!).
Technical description here

Following steps have to be proceeded:
1. Add the new language Code to "LIFERAY_ROOT_PATH"/WEB-INF/classes/portal(-ext).properties
##
## Language
##
locales=ar_SA,ca_AD,ca_ES,zh_CN,zh_TW,cs_CZ,nl_NL,en_US,
en_GB
,fi_FI,fr_FR,de_DE,el_GR,hu_HU,it_IT,ja_JP,ko_KR,
nb_NO,fa_IR,pt_BR,ru_RU,es_ES,sv_SE,tr_TR,vi_VN

2. If you add an completly new language you need to add an language-xx.propteries (xx=new language) file to /WEB-INF/lib/portal-impl.jar//content. In this case (en_UK) it is not nessary to add a new file because english (en) is already defined.

3. Add an Language-Image to your theme (in classis-theme: /images/language/en_GB.png)

4. Restart Liferay

Jul 3, 2008

Add a portlet to Liferay 5 (deployed in Liferay's Portlet Container)

In this post i will discribe the manual deployment of portlets in WebSphere.
To get some information about the auto deployment of portlets in WebSphere, check out this post.
Manually installation of a portlet in liferays portlet container isnt an easy think but its doable.
I try to explain the procedure with an simple (self created) sample (non-struts) JSP-Portlet.

The portlet just prints out:
Hello - username - how are you?
Download it here

Steps:
1. Copy the JSP-Files of the portlet to "liferay_folder"/html/portlet/welcome/
("welcome" is the portlet name)
2. Add an <portlet>-entry to WEB-INF/portlet-custom.xml
<portlet>
<portlet-name>welcome</portlet-name>
<display-name>Welcome to Liferay 5</display-name>
<portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/portlet/welcome/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>

3. Add an entry to WEB-INF/liferay-portlet.xml
<portlet>
<portlet-name>welcome</portlet-name>
<struts-path>mnet_welcome</struts-path>
<restore-current-view>false</restore-current-view>
<private-request-attributes>false</private-request-attributes>
<ajaxable>false</ajaxable>
</portlet>

4. Add an entry to WEB-INF/liferay-display.xml
<category name="category.ownportlets">
<portlet id="welcome" />
</category>

5. Add an entry to the language-xx.property-files (located in WEB-INF/lib/portal-impl.jar)
5.1 Open portal-impl.jar//content/language-"your needed region codes".properties (Hint: use Winrar)
5.2 Add an entry for the portlet title
javax.portlet.title.welcome=Welcome
5.3 Add an entry fot the category name
category.ownportlets=Own portlets
5.4 Save portal-impl.jar

6. Restart server

7. After the restart it's possible to add the welcome-portlet via the "Add Application" menu

If you want to deploy a struts portlet you have to additionally edit the struts-config.xml and the tiles-def.xml.

If you downloaded a portlet form liferay.com its a bit easier.
Open the downloaded war-file and take a look at the delivered xml-files.
These files just contain the additional entries needed for this portlet.
Copy these entries and paste them in the xmls located in your liferay installation.
Also extract all resources (classes,jars, jsps) to the corresponding folder.
Restart the server and thats it.
Picture (maybe it helps :-) :

Alternative:
Use an ext-enviroment and choose websphere as app-server

Links:
http://wiki.liferay.com/index.php/How_to_create_a_simple_portlet


Jul 1, 2008

Deploy Liferay 5 in WebSphere Application Server 6.1

For the latest install guides click here
#####################################################

Several problems need to be solved before Liferay 5 works correct in WAS 6.1.
Steps for installation:
1. Add ibm-web-bnd.xmi and ibm-web-ext.xmi to the WEB-INF-folder in the Liferay 5 WAR-file. (These files determinate that WAS is compiling Liferay 5 with JRE/JDK 1.5).
2. Create the Liferay 5 datasource (jdbc/LiferayPool - take a look at this post)
3. Deploy Liferay 5 WAR-File (with dependencies)
4. Move the JAR-files icu4.jar and portlet.jar from "Liferay-Root-Path"/WEB-INF/lib/ to /"WebSphere System Root"/java/jre/lib/ext (or change class load order :)
5. Somehow the WAS JSP-Compiler doesn't accept a JSP-Print-Tag (<%=... %>)
which contains quotes or double quotes (' or "). So you need to rewrite/replace some JSP-Files.
Current list of not working JSP-files:

  • ../html/portal/layout/edit/common.jspf
  • ../html/portlet/tagged_content/display_full_content.jsp
  • ../html/portlet/enterprise_admin/edit_organization_profile.jspf
  • ../html/portlet/enterprise_admin/edit_role_permissions_resource.jsp
  • ../html/portlet/enterprise_admin/organisation_action.jsp
  • ../html/portlet/enterprise_admin/user_group_action.jsp
  • ../html/portelt/rss/configuration.jsp
  • ../html/portlet/wiki/page_iterator.jsp
  • ../html/portlet/calender/edit_event.jsp
You can download the correct JSP-Files here. This step seems not to be necessary in Liferay 5.1.2.

6. For Liferay 5.1.2 geronimo-annotation_1.0_spec-1.1.1.jar (contained in apache geronimo) needs to be added to /Web-INF/lib [Temp fix - not for production - some spring releated database errors still occure in Liferay 5.1.2]

7. Edit the jdbc data source for higher load (especially for Oracle Databases)
7.1 In administrative console go to Resources > JDBC > Data sources > jdbc/LiferayPool > Connection pool properties
7.2 Adjust the connection properties for your needs

Guideline:
Connection Timeout -> decrease
Maximum Connections -> increase dramatically
Minimum Connections -> 1
Reap time -> decrease
Unused timeout -> decrease dramatically
Aged timeout -> 0

8. For Liferay 5.1.2 you need to go to Enterprise Admin > Settings and adjust the virtual host value