 |
Instructions for developing customized Alfresco installs with Eclipse/Maven. |
Goals
The aims of this guide are to show the Maven way to:
- Create a new Maven pom.xml for your Alfresco application.
- Generate Eclipse configuration from the pom.xml
- Run your Alfresco web application under Eclipse
- Debug into the Alfresco source code from Eclipse
- Modify Alfresco configuration
- Deploy and release your Alfresco application
Eclipse setup
Memory settings
- Install Eclipse to default location
- Edit eclipse.ini which should look something like this. Watch out for whitespace in this file.
-vm
C:\java\jdk1.6.0_10\bin\java.exe
-vmargs
-Xms128M
-Xmx768M
-XX:PermSize=64M
-XX:MaxPermSize=256M
Plugins
Set up your workspace
- Create a new Eclipse workspace and configure the Maven repository
mkdir d:\workspace\myalfresco
cd d:\workspace\myalfresco
mvn eclipse:add-maven-repo -Declipse.workspace=.
Create a new Maven project
The Alfreso archetype
Sourcesense repository provide an Maven archetype for Alfresco.
I've installed this bat file on my Windows path.
@echo off
if "%1"=="" goto noparams
if "%2"=="" goto noparams
mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create -DarchetypeGroupId=com.sourcesense.alfresco -DarchetypeVersion=1.0.0 -DarchetypeArtifactId=maven-alfresco-extension-archetype -DremoteRepositories=http:
goto end
:noparams
echo mvn-create-alfresco company.com projectname
goto end
:end
pause
Setting the Subversion repository
TODO. Checking project into your source repository.
Generate Eclipse configuration
We generate configuration for Eclipse and the Maven Eclipse plugin.
mvn eclipse:eclipse
mvn eclipse:m2eclipse
Maven tip: I needed to clean an old version of the maven-eclipse-plugin from my repository for eclipse:m2eclipse to work.
Run your Alfresco web application
Setup Alfresco database
See the tools/mysql folder for sample create database script.
Setup the launch configuration
See the images below. Note that you will need to add extra memory parameters to the JRE.
-Xms256m -Xmx512m -XX:PermSize=128m

Start the container
I found on Windows I also needed to delete the ${log.dir} from log4j.properties.
Start the Jetty container.
[INFO] Starting jetty 6.1-SNAPSHOT ...
2008-06-29 19:35:17.698::INFO: No Transaction manager found - if your webapp requires one, please configure one.
2008-06-29 19:35:20.137:/alfresco:INFO: Loading Spring root WebApplicationContext
19:35:37,325 WARN [remoting.rmi.RmiRegistryFactoryBean] Could not detect RMI registry - creating new one
19:35:41,932 WARN [alfresco.util.OpenOfficeConnectionTester] A connection to OpenOffice could not be established.
19:35:47,109 INFO [domain.schema.SchemaBootstrap] Schema managed by database dialect org.hibernate.dialect.MySQLInnoDBDialect.
19:35:47,370 INFO [domain.schema.SchemaBootstrap] Executing database script C:\DOCUME~1\damon\LOCALS~1\Temp\Alfresco\AlfrescoSchemaCreate-org.hibernate.dialect.MySQLInnoDBDialect-14611.sql (Generated).
19:36:20,738 INFO [domain.schema.SchemaBootstrap] Executing database script C:\DOCUME~1\damon\LOCALS~1\Temp\Alfresco\AlfrescoSchemaUpdate-org.hibernate.dialect.MySQLInnoDBDialect-14612.sql (Copied from classpath:alfresco/dbscripts/create/2.1/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoPostCreate-2.1-FKIndexes.sql).
19:36:20,898 INFO [domain.schema.SchemaBootstrap] All executed statements written to file C:\DOCUME~1\damon\LOCALS~1\Temp\Alfresco\AlfrescoSchemaUpdate-All_Statements-14613.sql.
19:38:40,138 WARN [repo.admin.ConfigurationChecker] The Alfresco 'dir.root' property is set to a relative path './alf_data_jetty'. 'dir.root' should be overridden to point to a specific folder.
19:38:40,138 INFO [repo.admin.ConfigurationChecker] The Alfresco root data directory ('dir.root') is: .\alf_data_jetty
19:38:40,178 INFO [admin.patch.PatchExecuter] Checking for patches to apply ...
19:38:40,439 INFO [repo.module.ModuleServiceImpl] Found 0 module(s).
19:38:40,839 INFO [service.descriptor.DescriptorService] Alfresco JVM - v1.6.0_10-beta-b25; maximum heap size 508.063MB
19:38:40,839 INFO [service.descriptor.DescriptorService] Alfresco started (Community Network): Current version 2.1.0 (482) schema 64 - Installed version 2.1.0 (482) schema 64
2008-06-29 19:38:44.331::INFO: Started SelectChannelConnector@0.0.0.0:8080
And you should be able to view Alfresco on localhost.
Debug into the Alfresco source code
Add the following to the Jetty run launch configuration VM arguments and run the Jetty container again. See Remote debugging with Jetty for details.
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n
Then create a new "Remote Java Application" launch configuration setting the port to 4000 as above. Then debug that configuration. Switch to the Debug perspective and you should see that the remote debugger connected.
To test things worked Open Type AuthenticationServiceImpl and set a break point in the Authentication method.
Modify Alfresco configuration
Rebuilding the war
Each time we make a change to a java file we want to push the change out to Jetty. For now I do this by manually running war:exploded.
Using JavaRebel
Optional In order to make changes to java classes and see those changes immediately I add javarebel to my jetty launch configuration. Otherwise restart Jetty each time you make a change to a java class.
-noverify -javaagent:d:/apps/javarebel/javarebel.jar
Deploy and release your application
Todo.
Credits
Most of this document is a summary of the work by Gabriele Columbro of Sourcesense.