Quantcast
Viewing all articles
Browse latest Browse all 12

Setting Up a Dual-AMP Maven Project

On Wednesday I wrote about downsizing the monolithic project created from the Alfresco All-in-One Maven SDK archetype. My goal was to end up with a project that would only build and deploy the Alfresco repository AMP and Share JAR. After discussing with Gab Columbro, he suggested a more efficient solution of combining two AMP projects created from the AMP archetype. This ended up not only being easier to configure but the deployment process is faster and there is the added bonus of separating the repository and Share containers, which is a development best practice.

The following steps outline how I configured the two AMP projects to deploy to Jetty and run side-by-side. Note that I am on a Mac, so some of these instructions will be specific to my environment.

  1. Generate an AMP project for the repository extensions.
    mvn archetype:generate \
       -DarchetypeGroupId=org.alfresco.maven.archetype \
       -DarchetypeArtifactId=alfresco-amp-archetype \
       -DarchetypeVersion=1.0 -DgroupId=com.yourcompany \
       -Dversion=1.0-SNAPSHOT -DartifactId=alfresco
  2. Optionally disable CIFS and configure OpenOffice/JODConverter and ImageMagick by adding the following to “alfresco/src/test/properties/local/alfresco-global.properties”:
    cifs.enabled=false
    
    # The following configure the JOD converter and ImageMagick. 
    # Your settings may vary based on your environment.
    ooo.exe=/Applications/OpenOffice.org.app/Contents/MacOS/soffice
    ooo.enabled=false
    jodconverter.officeHome=/Applications/OpenOffice.org.app/Contents
    jodconverter.portNumbers=8100
    jodconverter.enabled=true
    img.root=/usr/local
    img.exe=${img.root}/bin/convert
    swf.exe=${img.root}/bin/pdf2swf
  3. For Mac systems, fix the ImageMagick configuration per Will Abson’s instructions.
  4. Start Jetty and verify it starts with no exceptions.
    mvn integration-test -Pamp-to-war
  5. Verify the deployment by logging in to “http://localhost:8080/alfresco”
  6. Generate an AMP project for the Share extensions.
    mvn archetype:generate \
       -DarchetypeGroupId=org.alfresco.maven.archetype \
       -DarchetypeArtifactId=alfresco-amp-archetype \
       -DarchetypeVersion=1.0 -DgroupId=com.yourcompany \
       -Dversion=1.0-SNAPSHOT -DartifactId=share
  7. Add the following connector to “share/jetty/jetty.xml” to allow it to run on a configurable port.
    <Configure id="Server" class="org.mortbay.jetty.Server">
        <New id="myDataSource" class="org.mortbay.jetty.plus.naming.Resource">
        	...
        </New>
        <Call name="addConnector">
            <Arg>
                <New class="org.mortbay.jetty.nio.SelectChannelConnector">
                    <Set name="host">
                        <Property name="jetty.host"
                           default="${jetty.host}" />
                    </Set>
                    <Set name="port">
                        <Property name="jetty.port"
                           default="${jetty.port}" />
                    </Set>
                </New>
            </Arg>
        </Call>
    </Configure>
  8. Add the following properties to “share/pom.xml”:
    <properties>
      ...
      <jetty.host>localhost</jetty.host>
      <jetty.port>8081</jetty.port>
      <alfresco.jetty.host>localhost</alfresco.jetty.host>
      <alfresco.jetty.port>8080</alfresco.jetty.port>
    </properties>
  9. Modify “share/src/test/properties/local/alfresco-global.properties” and comment out everything but the following, which Share needs:
    dir.root=${alfresco.data.location}
    
    db.driver=${alfresco.db.datasource.class}
    db.url=${alfresco.db.url}
    db.username=${alfresco.db.username}
    db.password=${alfresco.db.password}
    db.pool.initial=10
    db.pool.max=100
  10. Add the following properties to “share/src/test/properties/local/alfresco-global.properties” to allow the RMI service ports to be randomly selected and to instruct Share where to find the Alfresco repository:
    avm.rmi.service.port=0
    avmsync.rmi.service.port=0
    attribute.rmi.service.port=0
    authentication.rmi.service.port=0
    repo.rmi.service.port=0
    action.rmi.service.port=0
    wcm-deployment-receiver.rmi.service.port=0
    monitor.rmi.service.port=0
    
    share.server.scheme=http
    share.server.name=${jetty.host}
    share.server.port=${jetty.port}
    alfresco.server.scheme=http
    alfresco.server.name=${alfresco.jetty.host}
    alfresco.server.port=${alfresco.jetty.port}
    alfresco.webapp.name=alfresco
  11. Start Jetty and ensure it starts without exceptions.
    mvn integration-test -Dalfresco.client.war=share -Pamp-to-war
  12. Log in to Share at “http://localhost:8080/share” and verify everything is working correctly.

For more information about the AMP archetype, visit the SDK and usage pages.


Viewing all articles
Browse latest Browse all 12

Trending Articles