Monday Dec 21, 2009

Alfresco on Glassfish revised for 3.2r2

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:

web.xml

sun-web.xml

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:

dir.root=./alf_data

becomes:

dir.root=/var/alfresco/alf_data

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

Summary

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,

Troubleshooting

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.



        
    

Wednesday Nov 11, 2009

Time for a new Alfresco on Glassfish walkthrough

My Alfresco on Glassfish Walkthrough is over a year old now and is creaking at the seams a little so I plan to update it. Feel free to comment here on what the new walkthrough should cover, Glassfish v2.1 or v3? Solaris or OpenSolaris? Linux or Windows? Which DB (just MySQL or some other OSDB)?

In fact feel free to comment on anything you would like to see to do with running Alfresco (or any other (E)CMS app) on Sun gear.

Original blog entry: http://blogs.sun.com/mandy/entry/alfresco_on_glassfish_on_opensolaris

Cheers

Amanda

Friday Oct 10, 2008

Alfresco on Glassfish (short version)

I posted a complete walkthrough on how to get Alfresco up and running on Glassfish earlier . Here's a version for those who don't need all the detail.

Glassfish has an undocumented property that when used in conjunction with the Classloader Delegate feature will allow MyFaces libraries to be loaded before the JSF libraries. You set both of these in the server specific deployment descriptor which is named sun-web.xml and which lives in the WEB-INF directory of the War file. The complete file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
<sun-web-app>
 <class-loader delegate="false"/>
 <property name="useMyFaces" value="true"/>
</sun-web-app> 

So create the file, place it in a directory named WEB-INF and then add it to the alfresco.war file:

$ jar uvf alfresco.war WEB-INF/sun-web.xml
adding: WEB-INF/sun-web.xml(in = 316) (out= 236)(deflated 25%)

Then deploy the alfresco.war file. If you've done everything else that's needed, you should be able to fire up a browser and connect to Alfresco at http://localhost:8080/afresco

Alfresco on Glassfish

I recently posted an updated version of this walkthrough that covers Alfresco 3.2r2.

This walkthrough is for OpenSolaris, it was made on the b98 development build but I'd expect it to work on the release version of 2008.05. It probably works on all other platforms as well with some changes to the pathnames and some of the commands. I'll work on something similar for Solaris, Ubuntu and for Windows.

I've posted a shorter version for those who have previously tried to get it working but were just missing the vital ingredient.

Initial Setup

I'm going to assume you are doing this as a non-root user. If you do this as root, just drop the pfexec statement from any commands you issue.

First install Glassfish and MySQL:

$ pfexec pkg refresh 
$ pfexec pkg install glassfishv2 
$ pfexec pkg install SUNWmysql5

Unlike with the best tutorials, I won't first remind you to turn your system on or not to install the packages if they are already installed.

OpenSolaris has this nifty feature called SMF but we haven't yet managed to hook the installation of packages up such that Services are automatically registered with it yet although that should be there in the November release. For now run the following to register it:

$ pfexec svccfg import /var/svc/manifest/application/database/mysql.xml

and then start the MySQL service:

$ pfexec svcadm enable mysql

This will do all of the work required to get MySQL up and running for the first time. Now create a DB and a user to access it with.

$ /usr/mysql/50/bin/mysqladmin -u root create alfresco
$ /usr/mysql/50/bin/mysql -u root
mysql> grant all privileges on alfresco.\* to 'alfresco'@'%' identified by 'alfresco';
Query OK, 0 rows modified (0.00sec) 
mysql> grant all privileges on alfresco.\* to 'alfresco'@'localhost' identified by 'alfresco';
Query OK, 0 rows modified (0.00sec) 

Now setup a Glassfish domain:

$ pfexec /usr/sbin/asadmin create-domain --adminport 4848 domain1

You need a JDBC MySQL driver:

$ wget http://mysql.osuosl.org/Downloads/Connector-J/mysql-connector-java-5.1.6.tar.gz

The URL used for the MySQL JDBC driver is just one of many mirrors. You might be better off going to http://dev.mysql.com/downloads/connector/j/5.1.html and choosing where to get it from.

Unpack this somewhere and copy mysql-connector-java-5.1.6-bin.jar to the Glassfish domain's lib directory:

$ pfexec cp mysql-connector-java-5.1.6-bin.jar /var/appserver/domains/domain1/lib

While you are doing this you may as well create an alfresco directory in the same place, you'll need it later.

$ pfexec mkdir /var/appserver/domains/domain1/lib/classes/alfresco

Alfresco War file and configuration

This testing was done with Alfresco labs 3b, it should work with other versions, but if it doesn't post a comment on this blog and I'll look into it.

Next we'll need the Alfresco War file, which you can probably get like this:

$ wget http://us.dl.alfresco.com/build-1164/alfresco-labs-war-3b.tar.gz

But as that looks like a URI than might have been created by SkyNet a machine, you may need to fallback to going here:

http://wiki.alfresco.com/wiki/Installing_Labs_3#Linux_download_and_installation

Once you have it, extract the bundle somewhere, you won't need it after the setup is finished.

You now need to setup the Alfresco bits that aren't contained in the WAR file. From the directory in which you unpacked the Alfresco bundle, copy the entire contents of the extensions directory to the directory you created earlier:
$ pfexec cp -r extensions/\* /var/appserver/domains/domain1/lib/classes/alfresco

You don't want to copy over the extensions directory itself, just it's contents (extension and messages directories).

Alfresco needs somewhere to keep all of it's documents and indexes. This is usually named alf_data, if you don't specify a path to alf_data or the path doesn't exist it will create one for you... somewhere. Let's not leave things to chance and create one and then configure Alfresco to find it:

$ pfexec mkdir /var/alfresco/alf_data

Now cd to /var/appserver/domains/domain1/lib/classes/alfresco/extension and modify the config files so that Alfresco can find alf_data and can find the database. The files that need changing are:

custom-repository.properties 
custom-hibernate-dialog.properties

In custom-repository.properties do the following:

Uncomment the dir.root line and change it's path to /var/alfresco/alf_data

#dir.root=/srv/alfresco/alf_data

becomes:

dir.root=/var/alfresco/alf_data

Uncomment the db.username and db.password lines

#db.username=alfresco
#db.password=alfresco 

becomes:

db.username=alfresco
db.password=alfresco 

The last part of the file has sections for specific databases, by default it's setup to use Derby. Comment out the lines for derby and uncomment the lines for MySQL

db.driver=org.apache.derby.jdbc.EmbeddedDriver
db.url=jdbc:derby:data/derby_data/alfrescocreate=true
...
...
#db.driver=org.gjt.mm.mysql.Driver
#db.url=jdbc:mysql://localhost/alfresco

becomes

#db.driver=org.apache.derby.jdbc.EmbeddedDriver
#db.url=jdbc:derby:data/derby_data/alfrescocreate=true
...
...
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco

In custom-hibernate-dialog.properties, comment out the line for Derby and uncomment the line for MySQL

The Glassfish specific deployment descriptor

Now for the fun bit. Go to the directory in which you unpacked the Alfresco bundle, create a directory called WEB-INF and in that create a file called sun-web.xml with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
<sun-web-app>
 <class-loader delegate="false"/>
 <property name="useMyFaces" value="true"/>
</sun-web-app> 

and then add that file to the alfresco.war file:

$ jar uvf alfresco.war WEB-INF/sun-web.xml
adding: WEB-INF/sun-web.xml(in = 316) (out= 236)(deflated 25%)

You're now ready to start Glassfish and deploy alfresco.war to the Glassfish domain:

$ pfexec /usr/bin/asadmin start-domain domain1
$ /usr/sbin/asadmin deploy alfresco.war
Please enter the admin user name>admin
Please enter the admin password> 
Command deploy executed successfully

Now you should be able to fire up a browser and connect to Alfresco at http://localhost:8080/afresco

Summary

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. I'll post this on the Alfresco forums once I'm happy that nothing silly creeped in. Hopefully we can extend this to cover different setups and configurations.

At some point it would be nice to show how to get the PDF to Flash functionality working as currently that's missing,

Troubleshooting

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/extensions. Check that you've used the correct path and that the changes that you made to custom-repository.properties and custom-hibernate-dialog.properties are correct.

Remember to stop and start MySQL (if you need to) using svcadm.

The sun-web.xml file has along line in it, if you cut and paste make sure that it doesn't get split across multiple lines.

If you see any issues or mistakes then post a comment on this blog.


Thursday May 29, 2008

Pseudo Eclipse Workspace files for NetBeans/Alfresco

In my last blog entry I talked about the pages on the Alfresco Wiki that detailed how to setup NetBeans as an Alfresco Development Enviroment and for the Alfresco SDK. Those pages include details of how to setup a psuedo eclipse workspace for use with the NetBeans eclipse project importer plugin. We have the files describe in that process available in a zip file: metadata.zip

 

 
 

Monday May 26, 2008

Doing Alfresco stuff in NetBeans

We recently completed a project to detail the steps required to use NetBeans 6.x to build Alfresco and to run the Alfresco SDK. The results of this work can be found at the following links:

Creating an Alfresco Build Environment in NetBeans

Running the Alfresco SDK in NetBeans

Give them a try and feel free to add any feedback to this blog entry.

Thanks to Prem Kumar for doing all of the hard work on these docs.

About

Bloggity, blog

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today