This is an old revision of the document!


Setting up Alfresco on FreeBSD

Alfresco is an open-source content management system. It supports creating collaboration ‘sites’ as well as various document management features, including version control. It’s essentially the open-source counterpart to Microsoft’s SharePoint server. I decided to use Alfresco for the IEEE’s content management system for two reasons: first, it’s open source so there is no licensing BS to deal with. Second, it will (in theory) run natively in FreeBSD, mitigating any need to deal with virtual machines.

Alfresco is written in Java and comes as a WAR archive, designed to be used with Tomcat running under a separate instance of Apache. Tomcat is a cross-platform JSP implementation.

To start, I installed Tomcat from ports along with the Sun JDK version 1.6. I installed Alfresco following the instructions (copy the war archive into the webapps directory). I also set up the MySQL database so Alfresco could connect to it. Then I fired up Tomcat. It extracted the war archive and began to start Alfresco. However, Alfresco quickly errored out with a hundred or so line long Java stack dump. Drilling down to the middle (!?!) of the dump yielded the root cause of the crash:

Error creating bean with name 'Audit' defined in class path resource
[alfresco/bootstrap-context.xml]: Invocation of init method failed;
nested exception is org.alfresco.repo.audit.model.AuditModelException:
04120001 Failed to load audit model: file:/opt/alfresco/tomcat/webapps
/alfresco/WEB-INF/classes/alfresco/audit/alfresco-audit-repository.xml

I had no clue what was causing this. I tried installing the complete bundle of Alfresco, Tomcat, and Apache, but that failed with the same error message. So I tried switching to a different distribution of Java, starting with OpenJDK. This was also unsuccessful, failing with a different error message:

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'avmSyncServiceTransportRMI' defined in
class path resource [alfresco/remote-services-context.xml]:
Invocation of init method failed; nested exception is
java.rmi.server.ExportException: internal error: ObjID already
in use

This had me completely stumped as well. However, since it’s a different error message, it definitely pointed to a problem with the Java installation. After much messing around with different versions of Java, I managed to get it to start with the Sun JDK 1.5 package. Apparently they changed something in the XML handling code, breaking Alfresco (and probably a lot of other applications) on that particular version.

As expected at this point, Alfresco still didn’t work properly. It errored out at a different part, trying to set up the database tables:

00:45:17,851  INFO  [domain.schema.SchemaBootstrap] Executing
database script /opt/alfresco/tomcat/temp/Alfresco/Alfresco
Schema-MySQLInnoDBDialect-Update-64821.sql (Generated).
00:45:17,855  ERROR [domain.schema.SchemaBootstrap] Statement
execution failed:
 SQL:     create table JBPM_ACTION (
 ID_ bigint not null auto_increment,
 class char(1) not null,
 NAME_ varchar(255),
 ISPROPAGATIONALLOWED_ bit,
 ACTIONEXPRESSION_ varchar(255),
 ISASYNC_ bit,
 REFERENCEDACTION_ bigint,
 ACTIONDELEGATION_ bigint,
 EVENT_ bigint,
 PROCESSDEFINITION_ bigint,
 TIMERNAME_ varchar(255),
 DUEDATE_ varchar(255),
 REPEAT_ varchar(255),
 TRANSITIONNAME_ varchar(255),
 TIMERACTION_ bigint,
 EXPRESSION_ text,
 EVENTINDEX_ integer,
 EXCEPTIONHANDLER_ bigint,

EXCEPTIONHANDLERINDEX_ integer,
 primary key (ID_)
 ) type=InnoDB
 Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right
syntax to use near 'type=InnoDB' at
 line 22
 File: /opt/alfresco/tomcat/temp/Alfresco/AlfrescoSchema-MySQLInno
DBDialect-Update-64821.sql
 Line: 23

Apparently MySQL deprecated the ‘type’ directive in favor of the ‘engine’ directive after MySQL 5.2. Lame. So I had to reinstall a different version of mysql-server, mysql-client, and php-mysqli. After doing this and recreating the alfresco database for a clean slate, Alfresco failed again with the following error:

Exception in thread "main" java.lang.OutOfMemoryError: PermGen space

This thing has 8 gigs of RAM. It should not be running out of memory. Well, it turns out that Java allocates a certain amount of memory for some things unless it is told otherwise. To do so, all I had to do is edit /etc/rc.conf and add:

tomcat60_java_opts="-Xms512m -Xmx1024m -Xss1024k -XX:MaxPermSize=256m -XX:NewSize=256m"

After that, Alfresco starts flawlessly. Well, it does take about 10 minutes to so because Java is really slow, but it does start without crashing. So, in sum, here is what you need to do to install Alfresco on FreeBSD:

  1. Install java/jdk15
  2. Install database/mysql52-server
  3. Install www/tomcat6
  4. Install Alfresco to /usr/local/apache-tomcat-6.0/webapps/
  5. Create /opt/alfresco and chown it to www:www
  6. Edit /etc/rc.conf

And that should be pretty much all you need to do to get Alfresco running on FreeBSD 8.