Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

In order to simplify setting up such an automated workflow we provide maven archetypes to help with setting up maven projects to build plugins and assemble servers. As an example we'll describe setting up such a workflow for the liferay 4.4.1 portal. Note that this is two steps removed from a description of how to deploy liferay on geronimo, and one step removed from a description of how to build plugins for the liferay portal. For a completed example of such a workflow see the roller plugins at https://svn.apache.org/repos/asf/geronimo/plugins/roller/trunkImage Removed

Notes:

  1. The archetypes are not included in geronimo 2.1 but the snapshots should be readily available
  2. Some of this would not be necessary given a project built with maven in the first place
  3. As of writing, the server doesn't start. Hopefully we'll figure out why soon.

Process overview.

  1. Due to maven lifecycle improvements in the car-maven-plugin the assembly artifact only generates poms that work with Geronimo 2.1.1 or later. The archetypes are currently available only as snapshots from branches/2.1 and trunk.
  2. Maven tends to strip out all comments from the new pom.xml so a pom.sample.xml is included that has more comments on how to set up the pom.xml for common situations.
  3. Archetypes use some attributes (groupId, version) of parent projects when they exist. The instructions use this: for standalone use you may need to supply more command line options.
  4. Some of this would not be necessary given a project built with maven in the first place
  5. As of writing, the server starts (given enough memory) but the liferay portal doesn't show up. Hopefully we'll figure out why soon.

Process overview.

  1. Get the necessary artifacts into the local maven repo if they are not already available
  2. Construct the base maven project
  3. Use the maven war archetype to
  4. Get the necessary artifacts into the local maven repo if they are not already available
  5. Construct the base maven project
  6. Use the maven war archetype to build a project to modify the artifacts as necessary using for instance the maven-war-plugin overlay to remove dependencies from WEB-INF/lib so copies in geronimo's repository can be used
  7. Use the geronimo-plugin-archetype to build projects to build plugins for the components
  8. Use the geronimo-assembly-archetype to build a project to assemble the server.

...

Code Block
    <pluginRepositories>
        <pluginRepository>
            <id>apache-snapshots</id>
            <name>Apache Snapshots Repository</name>
            <url>http://people.apache.org/repo/m2-snapshot-repository</url>
            <layout>default</layout>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
                <checksumPolicy>ignore</checksumPolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories >

Repackage the liferay war

Note
titleNote on Geronimo Versions

Unless you are using a published archetype that goes with the version of geronimo you are using, you will have to update the <geronimoVersion> property in the generated poms to whatever the correct version is. For instance as of writing the generated poms have <geronimoVersion>2.2-SNAPSHOT</geronimoVersion> and for use with geronimo 2.1 you would update this to <geronimoVersion>2.1</geronimoVersion>

Repackage the liferay war

The JEE spec tells us to package jars used by an application in with the application in WEB-INF/The JEE spec tells us to package jars used by an application in with the application in WEB-INF/lib or lib directories. This may appear to make the application more self contained but it can produce a tracking nightmare as it becomes more difficult to determine exactly what is in these directories, what version is being used, etc etc, not to mention promoting duplication of code used by several projects. Geronimo instead lets you put your jars in the maven-structured geronimo repository and specify the classloader structure for your apps to include these jars where necessary. If you want to convert an existing war project to this repository-based classloader solution you probably need to remove some of the jars from the existing war. You can do this easily with maven war overlays. For each jar you want to use from the geronimo repository, you specify an exclude in the overlay configuration and add the jar as a dependency in the maven project that builds the geronimo plugin. This example only excludes a few jars, most of which are already present in the parent classloader.

Code Block
mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-webapp \
  -DarchetypeVersion=1.0 \
  -DgroupId=com.liferay \
  -DartifactId=liferay-portal-lesslibs \
  -Dversion=4.4.1-NOLIB-SNAPSHOT
cd liferay-portal-lesslibs
rm -rf src

...

Code Block
        <dependency>
            <groupId>com.liferay</groupId>
            <artifactId>liferay-portal</artifactId>
            <version>${liferayVersion}<<version>4.4.1</version>
            <type>war</type>
	</dependency>

...

Code Block
mvn archetype:create \
  -DarchetypeGroupId=org.apache.geronimo.buildsupport \
  -DarchetypeArtifactId=geronimo-plugin-archetype \
  -DarchetypeVersion=2.2-SNAPSHOT \
  -DgroupId=org.apache.geronimo.plugins \
  -DartifactId=liferay-derby \
  -Dversion=1.0-SNAPSHOT
DartifactId=liferay-derby

Change the plan so it looks like this:

...

Code Block
mvn archetype:create \
  -DarchetypeGroupId=org.apache.geronimo.buildsupport \
  -DarchetypeArtifactId=geronimo-plugin-archetype \
  -DarchetypeVersion=2.2-SNAPSHOT \
  -DgroupId=org.apache.geronimo.plugins \
  -DartifactId=liferay-jetty \
  -Dversion=1.0-SNAPSHOT

Edit the plan so it looks like:
NOTE: this is derived from the liferay plan at and is under the liferay (MIT) license

Code Block
<?xml version="1.0"?>

<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">

    <environment>
        <inverse-classloading/>
    </environment>

	<context-root>${LiferayContextPath}</context-root>
	<security-realm-name>PortalRealm</security-realm-name>
      <security use-context-handler="false" xmlns="http://geronimo.apache.org/xml/ns/security-2.0">
<!-- requires security to be set up for default subject
        <default-subject>
          <realm>PortalRealm</realm>
          <id>default</id>
        </default-subject>
-->
        <role-mappings>
          <role role-name="users">
              <principal class="com.liferay.portal.security.jaas.PortalRole" name="users" />
          </role>
        </role-mappings>
      </security>

    <gbean name="CredentialStore" class="org.apache.geronimo.security.credentialstore.SimpleCredentialStoreImpl">
        <xml-attribute name="credentialStore">
            <credential-store xmlns="http://geronimo.apache.org/xml/ns/credentialstore-1.0">
                <realm name="PortalRealm">
                    <subject>
                        <id>default</id>
<!-- you will have so set up the backing store appropriately -->
                        <credential>
                            <type>org.apache.geronimo.security.credentialstore.NameCallbackHandler</type>
                            <value>anonymous</value>
                        </credential>
                        <credential>
                            <type>org.apache.geronimo.security.credentialstore.PasswordCallbackHandler</type>
                            <value>anonymous</value>
                        </credential>
                    </subject>
                </realm>
            </credential-store>
        </xml-attribute>
        <dependency>
            <name>PortalRealm</name>
        </dependency>
    </gbean>



	<gbean name="PortalRealm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
		<attribute name="realmName">PortalRealm</attribute>
		<reference name="ServerInfo">
			<name>ServerInfo</name>
		</reference>
		<xml-reference name="LoginModuleConfiguration">
			<log:login-config xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0">
				<log:login-module control-flag="REQUIRED" wrap-principals="false">
					<log:login-domain-name>PortalDomain</log:login-domain-name>
					<log:login-module-class>com.liferay.portal.security.jaas.ext.tomcat.PortalLoginModule</log:login-module-class>
				</log:login-module>
			</log:login-config>
		</xml-reference>
	</gbean>
</web-app>

and the pom to have geronimoVersion 2.1, liferayVersion 4.4.1 and include

</xml-reference>
	</gbean>
</web-app>

and the pom to have geronimoVersion 2.1, liferayVersion 4.4.1 and include

Code Block

    <dependencies>
        <!-- if you are deploying a jee application, use scope provided -->
        <!-- other dependencies will normally end up as dependencies in the plan and geronimo-plugin.xml -->
        <!-- include dependencies on all deployer modules needed, with scope provided -->

        <dependency>
  
Code Block

    <dependencies>
        <!-- if you are deploying a jee application, use scope provided -->
  <groupId>com.liferay</groupId>
            <artifactId>liferay-portal-lesslibs</artifactId>
           <!-- other dependencies will normally end up as dependencies in the plan and geronimo-plugin.xml -->
 <version>${liferayVersion}-SNAPSHOT</version>
            <type>war</type>
            <!-- include dependencies on all deployer modules needed, with scope provided -->

<scope>provided</scope>
	</dependency>
        <dependency>
            <dependency><groupId>org.apache.geronimo.configs</groupId>
            <groupId>com.liferay<<artifactId>javamail</groupId>artifactId>
            <artifactId>liferay-portal-lesslibs</artifactId><type>car</type>
            <version>${liferayVersiongeronimoVersion}</version>
            <type>war</type>
            <scope>provided</scope>
	</dependency>
</dependency>
<!-- replaces activemq jar in lib dir -->
        <dependency>
            <groupId>org.apache.geronimo.configs<activemq</groupId>
            <artifactId>javamail<<artifactId>activemq-core</artifactId>
            <type>car<<type>jar</type>
            <version>${geronimoVersion}<<version>4.1.1</version>
        </dependency>
<!-- replaces activemq jar in lib dir --> activemq car does not work because liferay wants to use spring to configure activemq.
 If we can eliminate the spring files in portal-impl.jar perhaps this would work.
        <dependency>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>activemq-ra</artifactId>
            <type>car</type>
            <version>${geronimoVersion}</version>
        </dependency>
-->
        <dependency>
            <groupId>org.apache.geronimo.plugins</groupId>
            <artifactId>liferay-derby</artifactId>
            <type>car</type>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>portlet-api</groupId>
            <artifactId>portlet-api</artifactId>
            <version>1.0</version>
	</dependency>
        <dependency>
            <groupId>com.liferay</groupId>
            <artifactId>portal-kernel</artifactId>
            <version>${liferayVersion}</version>
	</dependency>
        <dependency>
            <groupId>com.liferay</groupId>
            <artifactId>portal-service</artifactId>
            <version>${liferayVersion}</version>
	</dependency>

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.8.1</version>
	</dependency>

       <dependency>
            <groupId>saxpath</groupId>
            <artifactId>saxpath</artifactId>
            <version>1.0-FCS</version>
        </dependency>

        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>1.8</version>
        </dependency>

        <dependency>
            <groupId>org.apache.geronimo.framework</groupId>
            <artifactId>geronimo-gbean-deployer</artifactId>
            <type>car</type>
            <version>${geronimoVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>jetty6-deployer</artifactId>
            <type>car</type>
            <version>${geronimoVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>jasper-deployer</artifactId>
            <type>car</type>
            <version>${geronimoVersion}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.configs</groupId>
            <artifactId>persistence-jpa10-deployer</artifactId>
            <type>car</type>
            <version>${geronimoVersion}</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

...

Code Block
            <plugin>
                <groupId>org.apache.geronimo.buildsupport</groupId>
                <artifactId>car-maven-plugin</artifactId>
                <configuration>
                    <deploymentConfigs>
                        <!-- gbean deployer is default.  For jee apps include all deployers your app needs, see properties -->
                        <deploymentConfig>${gbeanDeployer}</deploymentConfig>
                        <deploymentConfig>${j2eeDeployer}</deploymentConfig>
                        <deploymentConfig>${jetty6Deployer}</deploymentConfig>
                        <deploymentConfig>${jasperDeployer}</deploymentConfig>
                        <!--<deploymentConfig>${jpaDeployer}</deploymentConfig>-->
                    </deploymentConfigs>
                    <!-- if you are deploying a jee app specify it here -->

                                        <module>
            <groupId>com.liferay</groupId>
            <artifactId>liferay-portal<portal-lesslibs</artifactId>
            <version>${liferayVersion}</version>
            <type>war</type>
                                        </module>

                    <!-- Normally you can use the maven dependencies unaltered.  If you need to specify import scope
                     you can list the dependencies here as you want them in the plan.xml -->
                    <useMavenDependencies>
                        <value>true</value>
                        <includeVersion>true</includeVersion>
                    </useMavenDependencies>
                    <!-- the instance sets up most of the optional geronimo-plugin.xml content -->
                    <instance>
                        <plugin-artifact>
                            <!-- extract stuff from the car to the specified location (good for config info -->
                            <!--<copy-file relative-to="server" dest-dir="var/roller-data">themes</copy-file>-->
                            <!-- content that should go into var/config/config.xml for module customization -->
                            <!-- note the variable ${LiferayContextPath} which is further specified in var/config/config-substitutions.properties -->

                                                        <config-xml-content server="default">
                                                            <gbean name="org.apache.geronimo.plugins/liferay-jetty/${liferayPluginVersion}/car">
                                                                <attribute name="contextPath">${LiferayContextPath}</attribute>
                                                            </gbean>
                                                        </config-xml-content>

                            <!-- a user-tweakable variable to go into var/config/config-substitutions.properties -->
                            <config-substitution key="LiferayContextPath">/liferay</config-substitution>
                        </plugin-artifact>
                    </instance>
                </configuration>
            </plugin>

...

Code Block
cd geronimo-jetty-liferay/target
tar xzf geronimo-jetty-liferay-1.0-SNAPSHOT-bin.tar.gz
cd geronimo-jetty-liferay-1.0-SNAPSHOT
#edit etc/rc.d/start-server,default.groovy
#insert line 
#command.javaFlags << '-XX:MaxPermSize=1024m'
#and update -Xmx1024m
./bin/gsh geronimo/start-server

As of writing this results in an OOM permGen the server will start but accessing http://localhost:8080/liferay redirects to http://localhost:8080/c and gives a 404 error.