Alfresco on Glassfish revised for 3.2r2
By MandyWaite on Dec 21, 2009
This is a walkthrough of installing Alfresco 3.2r2 on Glassfish v2 on OpenSolaris. I decided to start with the smallest delta from the original walkthrough so as to better get up to speed with the changes. Next I'll do the same for Glassfish v3 on OpenSolaris, CentOS and Windows. We can also look at deploying the share and mobile war files as well.
This walkthrough was performed on an OpenSolaris 2009.06 VM running in VirtualBox 3.0.12 on a Mac Book Pro running Snow Leopard. To run both MySQL, the App Server and Firefox you'll probably need at least 1.5GB of (v)RAM.
First you need to install the infrastructure, so install Glassfish v2 and MySQL 5.1 from the OpenSolaris repository:
$ pfexec pkg install glassfishv2 $ pfexec pkg install SUNWmysql51
We are going to assume that you are running as a user with the root role, so many of the commands are prefixed with pfexec. If you are doing this as root then you don't need to type pfexec.
Create a glassfish domain:
$ pfexec asadmin create-domain --adminport 4848 domain1
Download the MySQL JDBC connector from http://dev.mysql.com/downloads/connector/j/
Untar or unzip the bundle and from the extracted directory copy the mysql-connector-java-x.x.x-bin.jar file to the newly created glassfish domain's lib directory:
$ pfexec cp mysql-connector-java-5.1.10-bin.jar /var/appserver/domains/domain1/lib
There are some issues with MySQL in 32-bit mode on OpenSolaris so change the installed MySQL package to use 64-bit mode:
$ pfexec svccfg -s mysql:version_51 setprop mysql/enable_64bit=true $ svcadm refresh mysql:version_51 $ svcadm enable mysql:version_51 (or restart it if it's already running)
Now create the 'alfresco' db and the 'alfresco' user using the mysql client:
$ /usr/mysql/bin/mysql -u root
mysql> create database alfresco; mysql> grant all on alfresco.\* to 'alfresco'@'localhost' identified by 'alfresco';
Now download the Alfresco War file bundle which at the time of writing was named alfresco-community-war-3.2r2.tar.gz (there's also a .zip version) and was available from http://wiki.alfresco.com/wiki/Community_Edition_file_list_32r2
Create a new directory and untar/unzip the downloaded bundle into it. Change into that directory, here you'll find the alfresco.war file along with other optional parts of the Alfresco app. The Alfresco war file has a WEB-INF/web.xml deployment descriptor that doesn't comply with the DTD, you need to replace this file and add a Glassfish specific deployment descriptor that will allow Alfresco to use MyFaces instead of JSF. The two files are available here:
Create a new directory named WEB-INF and copy these files into it. Now update the alfresco.war file using the Java jar command:
$ jar -uvf alfresco.war WEB-INF/\*.xml
The jar command should output something similar to the following:
adding: WEB-INF/web.xml(in = 25157) (out= 3836)(deflated 84%) adding: WEB-INF/sun-web.xml(in = 317) (out= 237)(deflated 25%)
In this setup, by default Alfresco will create the alf_data directory in /var/appserver/domains/domain1/config which isn't the best place for it. To change the location you need to provide a configuration file that Alfresco can use at startup. First create the following directory:
$ pfexec mkdir -p /var/alfresco/alf_data
We'll use this directory for the walkthrough, feel free to replace /var/alfresco/alf_data with a path of your chosing.
Then (assuming you are in the same directory in which you untared/unzipped the Alfresco War file bundle) edit the file extensions/extension/alfresco-global.properties
$ vim extensions/extension/alfresco-global.properties
Near the top of the file is a line for 'dir.root' change that line as necessary for the path you are using, in our example case:
If you need to at any point, you can also specify alternative information for the MySQL DB in this file. Save the file and then copy it to the /var/appserver/domains/domain1/lib/classes which is on the Glassfish global classpath
$ pfexec cp extensions/extension/alfresco-global.properties /var/appserver/domains/domain1/lib/classes
Now start the Glassfish domain and deploy the alfresco.war:
$ pfexec asadmin start-domain $ asadmin deploy alfresco.war Please enter the admin user name>admin Please enter the admin password> Command deploy executed successfully
You should now be able to connect to http://localhost:8080/alfresco
This really just covers the basics and uses a
clean OpenSolaris install just to show what actually needs to be done
to get it working. Hopefully it can be extrapolated from to help
install Alfresco on Glassfish in more complicated scenarios.
At some point it would be nice to show how to get the PDF to Flash functionality working as currently that's missing,
Check that it's using the MySQL database that you created by connecting to MySQL through the mysql command and looking to see if the Alfresco database has a bunch of tables. Also check that /var/alfresco/alf_data contains directories if it doesn't then it probably hasn't picked up the configuration in /var/appserver/domains/domain1/lib/classes/alfresco-global.properties. Check that you've put the file in the correct path and that the changes that you made to to the file are correct.
If during setup you make a mistake and end up with a populated DB and an empty 'dir.root' or vice versa then stop the app server and drop the database and empty out dir.root (obviously don't do this if you have data store in Alfresco that you want to keep). Then restart the app server.
Alfresco will complain via the app server logs that it doesn't have the minimum amount of memory it requires to run (499 instead of 512), if you want to increase the amount of memory available to Glassfish take a look at the Glassfish docs.
If you see any issues or mistakes then post a comment on this blog.