Alexandre Hausherr's Blog

Alexandre Hausherr's Blog

Running Alfresco and Share separately with an AIO project using SDK 1.1.1 to 2.2.0

Why ?

When developping with Alfresco SDK with a All-in-one project, rebooting the app (running with mvn install –Prun ) to test a new line of code or a little fix takes a lot of time. Sometimes you just need to restart either Share or Alfresco, but in the cases where the command mvn refresh:share / mvn refresh:repo doesn't work you have to restart the whole server.

If the modification you want to test doesn't require Solr to be running (for SDK 2.X), the solution is to run Share and Alfresco separately, as you would do if your project only had two modules (share and repo) set with the archetypes share-amp and repo-amp, using the maven command mvn integration-test –Pamp-to-war on localhost:8080 for Alfresco and localhost:8081 for Share.

You can use this command in an All-in-one at the cost of some modifications in the files structure and the poms.

Required modifications

For all versions of Alfresco/SDK, add the following property to the share-amp module pom :

<maven.tomcat.port>8081</maven.tomcat.port>

Also create a folder tomcat under the root folder of the modules repo-amp and share-amp and a file named context.xml in the tomcat folders :

Then, depending on the version of Alfresco and of the SDK you are using, do the following :

Alfresco 4.2 / SDK 1.1.1

Content of repo-amp and share-amp context.xml :

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="${alfresco.client.war.folder}" path="${alfresco.client.contextPath}">
</Context>

Alfresco 5.0 / SDK 2.0.0

Just add the following property to the parent pom :

<alfresco.client.contextPath>/alfresco</alfresco.client.contextPath>

and the following property to the share-amp module pom :

<alfresco.client.contextPath>/share</alfresco.client.contextPath>

The context.xml files already exist and are properly set OOTB.

Alfresco 5.0.1+ / SDK 2.1.1

• Content of repo-amp context.xml :

<?xml version="1.0" encoding="UTF-8"?>

<Context docBase="${app.amp.client.war.folder}" path="${alfresco.client.contextPath}">

  <Resources className="org.apache.naming.resources.VirtualDirContext"
             extraResourcePaths="/=${project.build.directory}/${project.build.finalName}/web" />

    <Loader searchVirtualFirst="true"
            className="org.apache.catalina.loader.VirtualWebappLoader"
            virtualClasspath="${project.build.outputDirectory};${project.build.directory}/${project.build.finalName}/config;${project.build.testOutputDirectory}" />

    <JarScanner scanAllDirectories="true" />
</Context>

• Content of share-amp context.xml :

<?xml version="1.0" encoding="UTF-8"?>

<Context docBase="${app.amp.client.war.folder}" path="${share.client.contextPath}">

  <Resources className="org.apache.naming.resources.VirtualDirContext"
    extraResourcePaths="/=${project.build.directory}/${project.build.finalName}/web" />

  <Loader searchVirtualFirst="true"
          className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${project.build.outputDirectory};${project.build.directory}/${project.build.finalName}/config;${project.build.testOutputDirectory}" />

  <JarScanner scanAllDirectories="true" />
</Context>

Alfresco 5.1 / SDK 2.2.0

• Content of repo-amp context.xml :

<?xml version="1.0" encoding="UTF-8"?>

<Context path="${alfresco.client.contextPath}">
  <Resources className="org.apache.naming.resources.VirtualDirContext"
             extraResourcePaths="/=${project.build.directory}/amp/web,${app.amp.client.war.folder}" />

  <Loader searchVirtualFirst="true"
          className="org.apache.catalina.loader.VirtualWebappLoader"
          virtualClasspath="${project.build.outputDirectory};${project.build.directory}/amp/config;${project.build.testOutputDirectory}" />

  <JarScanner scanAllDirectories="true" />
</Context>

• Content of share-amp context.xml :

<?xml version="1.0" encoding="UTF-8"?>

<Context path="${share.client.contextPath}">
  <Resources className="org.apache.naming.resources.VirtualDirContext"
             extraResourcePaths="/=${project.build.directory}/amp/web,${app.amp.client.war.folder}" />

  <Loader searchVirtualFirst="true"
          className="org.apache.catalina.loader.VirtualWebappLoader"
          virtualClasspath="${project.build.outputDirectory};${project.build.directory}/amp/config;${project.build.testOutputDirectory}" />

  <JarScanner scanAllDirectories="true" />
</Context>
 
Share this