myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Myfaces Wiki] Update of "MavenLiferayPortlet" by GregReddin
Date Wed, 02 Aug 2006 16:40:17 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by GregReddin:

The comment on the change is:
Added Liferay and Maven 2 section

New page:
Maven makes it fairly easy to create a MyFaces portlet to deploy into Liferay.  This document
assumes you will be using Maven 2.0.4+ and Liferay 4.0.0+.  

== Create your POM file ==

You can use the Maven [ webapp archetype]
to create your project.  Your POM file will need to look something like this at a minimum.

<project xmlns="" xmlns:xsi=""
  <name>MyFaces Portlet</name>
         <name>MyFaces Staging Repository</name>

== Set up your web app. ==

In src/main/webapp/WEB-INF/web.xml you'll need to set up all your MyFaces stuff the way you
normally would.  It seems easier to use prefix mapping for the FacesServlet:


After creating your web application it's a good idea to test it in a standalone, non-portal
container to make sure everything works.

== Set up Logging ==

If you skip this step you will see the following in your Liferay Log when you try to deploy
or access the portlet.

19:49:04,765 ERROR [org.apache.catalina.startup.HostConfig] Error deploying web application
directory myfacesportlet
java.lang.NoSuchMethodError: org.apache.log4j.Category.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)V

        at org.apache.commons.logging.impl.Log4JCategoryLog.error(
        at org.apache.catalina.core.StandardContext.listenerStart(
        at org.apache.catalina.core.StandardContext.start(
        at org.apache.catalina.core.ContainerBase.addChildInternal(
        at org.apache.catalina.core.ContainerBase.addChild(
        at org.apache.catalina.core.StandardHost.addChild(
        at org.apache.catalina.startup.HostConfig.deployDirectory(
        at org.apache.catalina.startup.HostConfig.deployDirectories(
        at org.apache.catalina.startup.HostConfig.deployApps(
        at org.apache.catalina.startup.HostConfig.check(
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
        at org.apache.catalina.core.ContainerBase.backgroundProcess(
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
        at org.apache.catalina.core.ContainerBase$

To get rid of this exception create a file in src/main/resources
and add the following to it:


== Create Portlet and Liferay-specific Deployment Artifacts ==

Also, in src/main/webapp/WEB-INF you'll need to create 3 portal deployment files: portlet.xml,
liferay-portlet.xml, and liferay-display.xml.  They will be described below.

=== portlet.xml ===

This file is the standard Portlet deployment descriptor.  The most important distinction is
to set the {{{MyFacesGenericPortlet}}} as your portlet-class and make sure you set a default

<?xml version="1.0"?>

<portlet-app xmlns="" 
    version="1.0" xmlns:xsi="" 
        <display-name>Myfaces Test</display-name>
            <title>Myfaces Test</title>
            <short-title>Myfaces Test</short-title>
            <keywords>Myfaces Test</keywords>


=== liferay-portlet.xml ===

This is the Liferay-specific portlet deployment descriptor.  There is nothing special about
this file except that it is required for Liferay to see your portlet.

<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 4.0.0//EN" "">

            <role-link>Power User</role-link>

=== liferay-display.xml ===

This file tells Liferay how to make your portlet show up in its "Add Content" section so you
can add it to your pages.

<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 4.0.0//EN" "">

    <category name="category.test">
        <portlet id="myfaces_sample_portlet" />

== Build and Test ==

Again, it's a good idea to develop, build, and test your MyFaces portlet in a standalone container
like Tomcat.  This will ensure maximum portability.  It will allow you to deploy your components
in a standard web application or in a portal.  Make sure you note the portal-specific development
notes listed elsewhere.

== Add Liferay Dependencies ==

You will need to add Liferay's util-jsf.jar file in the WEB-INF/lib directory of your application.
 This file is not available on any public Maven repository.  You will either need to manually
place it in a local repo or manually insert it into your WAR file.

== Deploy Liferay WAR ==

Once you have a WAR file with all the dependencies as described in the previous step you can
use Liferay's deployment process to deploy the portlet into a running Liferay instance.  I
used the following Ant script to accomplish this task:

<project basedir="." name="target-liferay-deploy-tomcat">
    <target name="deploy">
        <!-- Tomcat -->
        <property name="liferay.portal.home" value="${user.home}/liferay-portal-tomcat-jdk5-4"/>
        <property name="app.server.dir" value="${liferay.portal.home}" />
        <property name="app.server.deploy.dir" value="${app.server.dir}/webapps" />
        <path id="project.classpath">
            <pathelement location="${env.ANT_HOME}/lib/ant.jar" />
            <fileset dir="${app.server.dir}/common/lib/ext" />
            <pathelement location="${app.server.dir}/liferay/WEB-INF/lib/portal-ejb.jar"
            <pathelement location="${app.server.dir}/liferay/WEB-INF/lib/util-java.jar"
            <pathelement location="${app.server.dir}/liferay/WEB-INF/lib/dom4j.jar" />
            <pathelement location="${app.server.dir}/liferay/WEB-INF/lib/concurrent.jar"
            <pathelement location="${app.server.dir}/liferay/WEB-INF/lib/trove.jar" />
            <pathelement location="${app.server.dir}/common/lib/servlet-api.jar" />


            <!-- Required Arguments -->
            <jvmarg value="-Ddeployer.base.dir=./" />
            <jvmarg value="-Ddeployer.dest.dir=${app.server.deploy.dir}" />
            <jvmarg value="" />
            <jvmarg value="-Ddeployer.portlet.taglib.dtd=${app.server.dir}/liferay/WEB-INF/tld/liferay-portlet.tld"

            <!-- Optional Arguments -->
            <jvmarg value="-Ddeployer.unpack.war=true" />
            <jvmarg value="-Ddeployer.jboss.prefix=1" />
            <jvmarg value="-Ddeployer.tomcat.lib.dir=${app.server.dir}/common/lib/ext"

            <!-- Dependent Libraries -->
            <arg value="${app.server.dir}/liferay/WEB-INF/lib/util-java.jar" />
            <arg value="${app.server.dir}/liferay/WEB-INF/lib/util-taglib.jar" />

Move your .WAR file into the directory where this ant script lives and type "ant deploy".

Log onto Liferay and test.

View raw message