AnsweredAssumed Answered

Getting FirstFoundationClient running in V4.0

Question asked by rjohnson on Mar 9, 2012
Latest reply on Jan 21, 2013 by melttech
I have recently struggled to get the Alfresco SDK V4.0 working properly, and whilst there are a fair few posts on the subject of getting the SDK example applications working, few of them cover V4.0 and many of them end without a fix.

This post is for those who might benefit from my experience of getting Alfresco V4.0  and the associated SDK working as a development environment.

My installation was done in a virtual machine running under VMWare Fusion on a MacBook Pro with 4Gb memory with a guest operating system of Ubuntu Linux 10.04 LTS 64 bit server using 2Gb of that memory. The instructions on changing the SDK example applications should work regardless of operating system. I chose Ubuntu 10.04 Server 64 bit as an operating system because:

    1. I already had Alfresco 4.0a running on it
    2. There is an Alfresco installer for it which I know works (see above)
    3. It doesn't need 20GB disk space just for the OS
    4. Most of the technologies in Alfresco originate from the Unix/Linux world
The only downside to the choice is that by default Ubuntu 10.04 LTS 64 bit server does not have a GUI which of course you need in order to run Eclipse.

To resolve this issue, go to the command line and issue the command

sudo apt-get update
sudo apt-get install -no-install-recommends ubuntu-desktop

This instals the GUI but without Evolution mail client or OpenOffice. The latter is important because Alfresco installs its own copy and I wanted to avoid any possible conflict.

Once installed you might want to install the Synaptic Package Manager. This is only a GUI for apt, but its easy to do just type:-

sudo apt-get install synaptic

Whilst not absolutely necessary it is helpful to install VMWare tools. This is fiddly because the VMWare process installs it as source which you have to compile up so (depending on what you chose to install with your base operating system) you may need to install gcc and development libraries and the linux kernel headers.

For that:-

sudo apt-get install build-essential
sudo apt-get install linux-headers-$(uname -r)

Having installed the GUI you need to add Firefox and the flash plugin or you will not be able to browse to Alfresco. You can do this using Synaptic.

Now you have Firefox on the "server" browse to Alfresco and download the installer for Alfresco 4.0d. its at from here. Follow the instructions on installing Alfresco and make sure that you have a working installation by browsing to the explorer AND logging in as admin. Logging in is important because it ensures that your installation is actually working (not just able to display a jsp login page and that you have an installation with an up to date schema.

Assuming that you have accepted the defaults on the install you have Alfresco, Java and PostgreSql (amongst other things) on your server which are all working fine and co-operating nicely.

Alfresco installs java as a subdirectory off the installation root so the chances are that your Java environment is not on your $PATH environment variable so you need to add it by editing your .profile.

I had installed Alfresco off my home directory so for me, I just had to add the line


to the end of my .profile file and then type . .profile at the command line or log off and log on again.

Check that you have a working Java installation that works outside the alfresco world by going to your home directory and entering java -version, assuming you get a response telling you your java version is 1.6.0_22 - your on.

Now browse to the Eclipse web site and download and install Eclipse Indigo JaveEE edition and install it. I installed it off my home directory.

Now download the Alfresco SDK for V4.0 from here and follow the instructions at to install it (I put it into a subdirectory SDK off my alfresco root directory) and import the projects into Eclipse (don't try and run the FirstFoundationClient because things will not work). Please note that there is a link to 4.0c community edition on the 4.0 page. This is a bit out of date and you need to go for the 4.0d version.

The SDK examples rely on the project SDK AlfrescoEmbedded which is included in the other examples to provide references, standard functionality and the library code required. If you try and run FirstFoundationClient you will get some exceptions about missing classes. To prevent this you need to open the SDK AlfrescoEmbedded project and right click Properties -> Java Build Path and then flick to the Libraries tab and select "Add External JARs" browse to your {alfresco-root}/SDK/lib/server directory and add alfresco-vti-4.0.d.jar, jetty-6.1.26.jar, jetty-util-6.1.26.jar.

Now go to the {alfresco-root}/tomcat/shared/classes and copy into {alfresco-root}/SDK/samples/FirstFoundationClient/build

Using Eclipse, open FirstFoundationClient and edit and add the lines

### hibernate settings ###
hibernate.query.substitutions=true TRUE, false FALSE

One thing I found out the hard way is that the Java VM arguments in eclipse.ini relate solely to the java instance running the Eclipse IDE. When you launch your project you get a separate java environment which has default values for memory allocation and consequently does not have enough PermGen. So, open the Properties on the Project and click Run/Debug settings then click on SDK FirstFoundationClient and then Edit. Go to the arguments tab and in the VM arguments box enter

-Xms40m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m

and click "Apply" then "OK" and "OK"

Repeat that on the Bootstrap and

Now the really tricky bit. Unless you have restarted your computer you have alfresco (maybe share), postgresql and solr running. FirstFoundationClient won't run with alfresco and/or share running but you have to have postgreSql and solr running.

First, stop everything; so go to the installation root of Alfresco and type

./ stop

That will (should) kill everything and your machine is as it would be if you rebooted it.

First start PostgreSql; go to {alfresco-root}/postgresql/scripts and type

./ start

Now you need to start the solr web application but only the solr webapp. I found no way of controlling what started under tomcat (which I don't doubt is my ignorance) so I had to rename the war files. To do this, go to {alfresco-root}/tomcat/webapps and rename alfresco.war and share.war to alfresco.war.stop and share.war.stop respectively. Now go to {alfresco-root}/tomcat/scripts and type

./ start

What you now have is a working postgreSql database and the solr indexing.

Open FirstFoundationClient and find the line

authenticationService.authenticate("admin", "admin".toCharArray());

and change the user name (first admin) and password (second admin) to the admin username and password you set when installing Alfresco.

Now go to Eclipse, select the (if you prefer you can select the project SDK FirstFoundationClient), right click and select run as java application and, if I have remembered everything you should get

09-Mar-2012 20:20:06 org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
09-Mar-2012 20:20:17 org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine activitiBootstrapEngine created
09-Mar-2012 20:20:17 org.activiti.engine.impl.jobexecutor.JobAcquisitionThread run
INFO: JobAcquisitionThread starting to acquire jobs

Which means it ran properly.You will get to this text quite early on in execution, the program has only succeeded when the little red square above the box with this text in it goes grey.

Whilst testing these instructions I unexpectedly got an error on VtiServer which was port in use. VtiServer uses port 7070 an sure enough there was part of gnome sitting on that port.  This shouldn't happen and re-booting the virtual machine removed this and the application ran properly. To avoid excitement like this you can open a console window and type

netstat -an | grep "7070" and provided it comes back with nothing, you should not get this problem. If it does return a row, reboot your VM and try again.

To prove that, go to {alfresco-root}/tomcat/scripts and type

./ stop

then go to {alfresco-root}/webapps and rename alfresco.war.stop and share.war.stop to alfresco.war and share.war respectively. Restart tomcat by going to {alfresco-root}/tomcat/scripts and then type

./ start

Now browse to alfresco explorer (localhost:8080/alfresco) and log in as admin. In Company Home you should see a new file with a name similar to:

Foundation API sample (1331165238336)

Note that the number will vary, but Its contents will be

The quick brown fox jumps over the lazy dog

I spent many hours getting this working, maybe I'm just thick, but I hope that this write up is of some help to someone. If you try this and you have difficulty, add a reply and I will try and assist.