Building Alfresco 6 CE from Sources (I)

by Lutz Horn
Categories: alfresco
cover-image

We at ecm4u GmbH rely on Alfresco CE as the base for many customer installations. Sometimes we must make small changes to the sources, we fix bugs or add small features. To be able to do this, we created clones of the 5.2 projects and made them avaible to the public (alfresco-ce-repository, alfresco-data-model, share). Building these projects was as easy as running a simple mvn install.

Not anymore.

Building Alfresco 6 - What are the required modules?

Building Alfresco 6 aka Alfresco 201901 GA CE from sources is not as easy as it was for Alfresco 5.2. First we have to find out which modules are part of this release. The release notes point us to acs-community-deployment. OK, let's clone this.

$ git clone https://github.com/Alfresco/acs-community-deployment.git
$ git checkout tags/2.2.0

But where are the sources? This is not even a Maven project!

There are many more projects on GitHub, one being acs-community-packaging. Let's take a look.

$ git clone https://github.com/Alfresco/acs-community-packaging.git
$ git checkout tags/acs-community-packaging-6.1.2-ga

That looks better. Here we have a pom.xml that tells us about the versions of the other projects that are part of this release.

<dependency.alfresco-core.version>7.5</dependency.alfresco-core.version>
<dependency.alfresco-data-model.version>8.25</dependency.alfresco-data-model.version>
<dependency.alfresco-repository.version>7.43</dependency.alfresco-repository.version>
<dependency.alfresco-remote-api.version>7.35</dependency.alfresco-remote-api.version>
<dependency.alfresco-hb-data-sender.version>1.0.9</dependency.alfresco-hb-data-sender.version>
<dependency.alfresco-spring-webscripts.version>6.20</dependency.alfresco-spring-webscripts.version>
<dependency.alfresco-mmt.version>6.0</dependency.alfresco-mmt.version>
<dependency.alfresco-pdf-renderer.version>1.1</dependency.alfresco-pdf-renderer.version>
<dependency.alfresco-trashcan-cleaner.version>2.3</dependency.alfresco-trashcan-cleaner.version>
<dependency.alfresco-jlan.version>7.1</dependency.alfresco-jlan.version>
<dependency.alfresco-server-root.version>6.0.1</dependency.alfresco-server-root.version>
<dependency.alfresco-messaging-repo.version>1.2.9</dependency.alfresco-messaging-repo.version>
<dependency.alfresco-api-explorer.version>6.1.0-RC4</dependency.alfresco-api-explorer.version>

Building alfresco-core

Let's start with the first module alfresco-core.

$ git clone https://github.com/Alfresco/alfresco-core.git
$ git checkout tags/7.5
$ mvn package
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Great!

Building alfresco-data-model

On to the next module alfresco-data-model.

$ git clone https://github.com/Alfresco/alfresco-data-model.git
$ git checkout tags/8.25
$ mvn package
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

That was easy.

Building alfresco-repository

This is the main module.

$ git clone https://github.com/Alfresco/alfresco-repository.git
$ git checkout tags/7.43
error: pathspec 'tags/7.43' did not match any file(s) known to git.

What? 7.43 is the version listed in the pom.xml of acs-community-packaging, why is there no tag for it?

$ git tag | grep 7.43
alfresco-repository-7.43

OK, so the tag names don't directly match the versions. Confusing. Let's checkout the existing tag.

$ git checkout tags/alfresco-repository-7.43
$ mvn package

As expected, this takes a while. But as soon as the unit tests are executed, exceptions come flying by.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialect': FactoryBean threw exception on object creation; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL ''
        at org.alfresco.encryption.KeyStoreTests.<clinit>(KeyStoreTests.java:68)
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL ''
        at org.alfresco.encryption.KeyStoreTests.<clinit>(KeyStoreTests.java:68)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL ''
        at org.alfresco.encryption.KeyStoreTests.<clinit>(KeyStoreTests.java:68)
Caused by: java.sql.SQLException: No suitable driver
        at org.alfresco.encryption.KeyStoreTests.<clinit>(KeyStoreTests.java:68)

Why are the driver class and the connection URL empty? Didn't the README.md tell us that "The project can be built by running Maven command: mvn clean install"?

But wait, then it says this:

All of these classes as well as individual tests can be run by specifying the test class name and a set of DB connection properties, for example:

mvn clean test -Dtest=SomeRepoTest -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql:alfresco -Ddb.username=alfresco -Ddb.password=alfresco

Well, these connection properties aren't optional, they are mandatory. But before we can connect to any database, we will have to create one. We will use a PostgreSQL database for my local Linux user.

$ createdb alfresco-6
$ mvn test \
  -Ddb.driver=org.postgresql.Driver \
  -Ddb.name=alfresco-6 \
  -Ddb.url=jdbc:postgresql:alfresco-6 \
  -Ddb.username=lutz \
  -Ddb.password=lutz

The first unit test is started but then no progress is made.

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.alfresco.RepositoryStartStopTest

What is happening? The unit test writes to a log file at

target/surefire-reports/org.alfresco.RepositoryStartStopTest-output.txt:

...
 2019-04-11 12:44:47,369  INFO  [repo.thumbnail.ThumbnailRegistry] [main] Init'ed thumbnail defs in 341 ms
 2019-04-11 12:44:47,480  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,488  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,492  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,495  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,498  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,500  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,505  DEBUG [repo.action.ActionServiceImpl] [main] Retrieving 0 conditions
 2019-04-11 12:44:47,570  INFO  [management.subsystems.ChildApplicationContextFactory] [main] Starting 'Messaging' subsystem, ID: [Messaging, default]
 2019-04-11 12:45:05,658  DEBUG [repo.transaction.RetryingTransactionHelper] [JobLockService1]
Transaction commit failed:
   Thread: JobLockService1
   Txn:    UserTransaction[object=org.alfresco.util.transaction.SpringAwareUserTransaction@429dfd32, status=6]
   Iteration: 0
   Exception follows:
 org.alfresco.util.transaction.ConnectionPoolException: 03110072 The DB connection pool is depleted.
        at org.alfresco.util.transaction.SpringAwareUserTransaction.begin(SpringAwareUserTransaction.java:418)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:439)
        at org.alfresco.repo.lock.JobLockServiceImpl.releaseLockVerify(JobLockServiceImpl.java:477)
        at org.alfresco.repo.lock.JobLockServiceImpl$2.run(JobLockServiceImpl.java:385)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Data source is closed
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:305)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:474)
        at org.alfresco.util.transaction.SpringAwareUserTransaction.begin(SpringAwareUserTransaction.java:413)
        ... 10 more
Caused by: java.sql.SQLException: Data source is closed
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1362)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
        at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:262)
        ... 13 more

Why is the data source closed? Looking into PostgreSQL, we see 11 connections coming via JDBC:

lutz@localhost:alfresco-6> select usename, application_name, query from pg_stat_activity where datname = 'alfresco-6';
+-----------+------------------------+--------------------------------------------------------------------------------------------+
| usename   | application_name       | query                                                                                      |
|-----------+------------------------+--------------------------------------------------------------------------------------------|
| lutz      | PostgreSQL JDBC Driver | SET application_name = 'PostgreSQL JDBC Driver'                                            |
| lutz      | PostgreSQL JDBC Driver | SET application_name = 'PostgreSQL JDBC Driver'                                            |
| lutz      | PostgreSQL JDBC Driver | SET application_name = 'PostgreSQL JDBC Driver'                                            |
| lutz      | PostgreSQL JDBC Driver | SET application_name = 'PostgreSQL JDBC Driver'                                            |
| lutz      | PostgreSQL JDBC Driver | COMMIT                                                                                     |
| lutz      | PostgreSQL JDBC Driver | COMMIT                                                                                     |
| lutz      | PostgreSQL JDBC Driver | COMMIT                                                                                     |
| lutz      | PostgreSQL JDBC Driver | COMMIT                                                                                     |
| lutz      | PostgreSQL JDBC Driver | COMMIT                                                                                     |
| lutz      | PostgreSQL JDBC Driver | COMMIT                                                                                     |
| lutz      | PostgreSQL JDBC Driver | SET application_name = 'PostgreSQL JDBC Driver'                                            |
| lutz      | pgcli                  | select usename, application_name, query from pg_stat_activity where datname = 'alfresco-6' |
+-----------+------------------------+--------------------------------------------------------------------------------------------+
SELECT 12

This hangs until we kill Maven.

Contet objects are created so it looks as if the Alfresco Repository has started.

 tree target/alf_data/contentstore | head
target/alf_data/contentstore
└── 2019
    └── 4
        └── 11
            └── 12
                └── 44
                    ├── 00e71591-c66b-4413-84b9-80a163533814.bin
                    ├── 04c89936-3f38-41ea-a078-84a570ebe42b.bin
                    ├── 05d2a453-4f52-4e47-9eea-bed8b31a6f4b.bin
                    ├── 0686dc22-ccaf-4e63-8979-9f783e3d9a3e.bin

But what did we miss?

More to come

Sadly, that's as far as we got trying to build Alfresco 201901 GA CE from sources. We will continue with Part 2 as soon as we are able to make any progress.


Picture credits: rawpixel licenced under the pixabay license (free for commercial use)