A little bit of history...
Local development prior to using the Amp Archetype had been the following below list. It's worked out well, and I find it very stable. I'll go back to doing it this way if I find any limitations in the embedded tomcat/H2 DB/lucene version.
- Download the windows .exe or linux .bin self extracting/installing files
- Configure non-postgresql DB for use if necessary with alfresco-global.properties in the shared classes location
- Configure a custom-log4j.properties in the shared classes extension location
- Both alfresco and share wars installed on the same container
- Make .bat/.sh script to install amp into war and deploy to target container location
- Make .bat/.sh script to recursively copy from the source code amp location to the installed war location for files that don't require a container restart
- Enable Jrebel support for any Java changes (view my previous post on that)
- Good to get most developers up and running
- Good you can change the alfresco version on the fly in the pom
- Bad because:
- SLOW to start up (9 mins on my machine)
- Can't control tomcat to the extent of if you deployed manually (Not all bin or conf files were available)
- Doesn't match what the target environment would use
- Comes with a default alfresco-global.properties which is completely different than the standard alfresco install sample file.
- Both alfresco and share are included, if you don't need share, then you don't need share
- The log4j.properties was contained in the amp when built
- Yes we can have multiple log4j.properties in the classpath, and yes there are classpath loading orders, but I've always found it clearer to just use a custom-log4j.properties in the shared classes alfresco extension folder to override any OOB alfresco WEB-INF/classes/log4j.properties file
Tweaking the maven template output after creating the Amp-Archetype
I decided to try the Amp-Archetype to see if I would like it better. I am a real fan now. It's much faster to start the embedded containers, and it's a good idea to separate out alfresco and share in it's own containers, since you only need to start alfresco if you need to work on it that day. This article helped immensely to set it up.
Here's how I tweaked the template output after creating the archetype:
- One amp-archetype for alfresco and a separate one for share
- Improvement: the Amp Archetype should be split in an Amp-Repo-Archetype and a Amp-Share-Archetype possibly since the files needed would be slightly different.
- Alfresco
- Added additional properties to the OOB src/test/resources/alfresco-global.properties to recognize what share is running, since share is running on a different port
- Deleted:
- All log4j.properties files. I am using custom-log4j.properties instead
- src/main/amp/config/alfresco/module/<artifact id>/log4j.properties
- src/main/amp/log4j.properties
- src/test/resources/log4j.properties
- All the Demo components. Nice to have for newbies to alfresco, but I didn't need it. Plus the build was running an integration test which makes it slow
- Added:
- src/test/resources/alfresco/extension/custom-log4j.properties
- Takes approximately two minutes to start up if I include the maven clean build phase
- Share
- Note: Kept the src/test/resources/log4j.properties file.
- Had to copy over the share OOB log4j.properties into it, then add my customizations on top
- Could also use same strategy for custom-log4j.properties as alfresco here
- Deleted:
- src/test/properties/local/alfresco-global.properties. This is only for the Alfresco repository, not needed for share
- src/main/amp/config/alfresco/module/<artifact id>/log4j.properties
- src/main/amp/log4j.properties
- All the Demo components. Demo components are for Alfresco repo, not share
- Takes approximately two minutes to start up if I include the maven clean build phase
- For both alfresco and share:
- In the root maven module folder:
- Created a .bat/.sh file to start alfresco/share. It defines the DEBUG_OPTS, MAVEN_OPTS, JAVA_HOME, MAVEN_HOME, and a flag to start with JRebel or non-JRebel support (reference this article and this article)
- Created a .bat/.sh file to recursively copy from the amp location to the installed war location for files that don't require a container restart
- runAlfresco.bat
rem Instructions for starting local Alfresco Repository rem Make sure to change the following: rem 1. Folder to your alfresco explorer maven alfresco sdk rem 2. Debug port can be used on your workstation. NOTE: the debug option shouldn't be turned on on a production server rem 3. Java Home rem 4. Maven Home rem 5. You can change the port this runs on if necessary: -Dmaven.tomcat.port=8081 rem 6. If running with rad and jrebel, the JREBEL_OPTS set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n set MAVEN_OPTS=%DEBUG_OPTS% -Xms1024m -Xmx4096m -XX:PermSize=1024m set JAVA_HOME=C:\Apps\Java\jdk1.7.0_67 set MAVEN_HOME=C:\Apps\apache-maven-3.2.2 mvn clean integration-test -Pamp-to-war rem If you have a jrebel license then: comment out the above mvn line, and uncomment out the below 3 lines to run with jrebel rem set JREBEL_OPTS=-javaagent:C:\Apps\jrebel\jrebel.jar -noverify rem set MAVEN_OPTS=%MAVEN_OPTS% %JREBEL_OPTS% rem mvn clean integration-test -Pamp-to-war,rad
- runShare.bat
rem Instructions for starting local Share rem Make sure to change the following: rem 1. Folder to your alfresco share maven alfresco sdk rem 2. Debug port can be used on your workstation. NOTE: the debug option shouldn't be turned on on a production server rem 3. Java Home rem 4. Maven Home rem 5. You can change the port this runs on if necessary: -Dmaven.tomcat.port=8081 (then you also have to change alfresco module alfresco-global.properties) rem 6. If running with rad and jrebel, the JREBEL_OPTS set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1045,server=y,suspend=n set MAVEN_OPTS=%DEBUG_OPTS% -Xms1024m -Xmx4096m -XX:PermSize=1024m set JAVA_HOME=C:\Apps\Java\jdk1.7.0_67 set MAVEN_HOME=C:\Apps\apache-maven-3.2.2 mvn clean integration-test -Pamp-to-war -Dmaven.tomcat.port=8081 rem If you have a jrebel license then: comment out the above mvn line, and uncomment out the below 3 lines to run with jrebel rem set JREBEL_OPTS=-javaagent:C:\Apps\jrebel\jrebel.jar -noverify rem set MAVEN_OPTS=%MAVEN_OPTS% %JREBEL_OPTS% rem mvn clean integration-test -Pamp-to-war,rad -Dmaven.tomcat.port=8081
For more examples and ideas, I encourage you explore the links provided throughout this blog. What questions do you have about this post? Let me know in the comments section below, and I will answer each one.
NOTE, to make this work with alfresco enterprise version, do the following:
NOTE, to make this work with alfresco enterprise version, do the following:
- Add alfresco nexus private repo server info to .m2 settings.xml file
<!-- Needed for alfresco private repo --> <server> <id>alfresco-artifacts-repository</id> <username>yourusername</username> <password>yourpassword</password> </server>
- Add private alfresco nexus repository to pom. Note the private repository name must match the server id you added in settings.xml in the previous step.
<repositories> <!-- add private repo for enterprise --> <repository> <id>alfresco-artifacts-repository</id> <url>https://artifacts.alfresco.com/nexus/content/groups/private</url> </repository> <repository> <id>alfresco-artifacts</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public</url> </repository> <repository> <id>alfresco-artifacts-snapshots</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url> </repository> </repositories>
- You may have to change the alfresco.groupId and alfresco.client.war.groupId values, depending on the alfresco enterprise version you are using (i.e. 4.1.x is in org.alfresco.enterprise, but 4.2.x is in org.enterprise!).
- In properties, change the group id to enterprise for both (instead of org.alfresco, use org.alfresco.enterprise).
<alfresco.groupId>org.alfresco.enterprise</alfresco.groupId> <alfresco.client.war.groupId>org.alfresco.enterprise</alfresco.client.war.groupId>
I'm sorry for commenting the old post. However, I'd like to leave this message here for people like me, who will find this post while trying to debug slow Alfresco startup when using Alfresco Maven SDK.
ReplyDeleteI experienced exactly this issue today, and 9 minutes to start is definitely not normal for Alfresco. There is a chance, that you are hit by network misconfiguration, as described here - http://blog.itdhq.com/post/133135613685/alfresco-sdk-fixing-mysteriously-slow-tomcat
Thanks for your comment.
DeleteI'm curious, did you see the slowness (and java.net.Inet6AddressImpl.lookupAllHostAddr() code) using the all in one archetype or the amp archetype? I only saw the slowness using the all in one archetype.