cancel
Showing results for 
Search instead for 
Did you mean: 

Getting FirstFoundationClient running in V4.0

rjohnson
Star Contributor
Star Contributor
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 http://wiki.alfresco.com/wiki/Community_file_list_4.0.d. 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

PATH="$HOME/alfresco-4.0.d/java/bin:$PATH"

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 herehttps://process.alfresco.com/ccdl/?file=release/community/build-4003/alfresco-community-sdk-4.0.d.zi... and follow the instructions at http://wiki.alfresco.com/wiki/Alfresco_SDK_4.0 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 alfresco-global.properties into {alfresco-root}/SDK/samples/FirstFoundationClient/build

Using Eclipse, open FirstFoundationClient and edit alfreso-global.properties and add the lines

### hibernate settings ###
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
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 FirstFoundationClient.java

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

./alfresco.sh 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

./ctl.sh 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

./ctl.sh 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 FirstFoundationClient.java (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

./ctl.sh 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

./ctl.sh 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.
9 REPLIES 9

mrogers
Star Contributor
Star Contributor
Thanks for the posting.

I've updated the wiki page to point to 4.0.d and raised an issue in JIRA to consider how the introduction of SOLR affects the Embedded projects of the SDK.

dnallsopp
Champ in-the-making
Champ in-the-making
Thanks very much indeed for posting - I too spent ages trying to get this working (which is pretty demoralising for a 'Hello World' type example!).

On Windows XP, with Alfresco Community V4.0.d, I did not need to add the hibernate settings, though I did need to manually start PostgreSQL since the scripts in the Start Menu shut down both Tomcat and Postgres.

I didn't get any exceptions about missing classes.

I didn't put alfresco-global.properties into {alfresco-root}/SDK/samples/FirstFoundationClient/build - this folder doesn't seem to exist? I am still not sure what the correct location(s) are - because of earlier trial-and-error (and sheer desperation) I have one copy in {alfresco-root}/SDK/samples/FirstFoundationClient and another in {alfresco-root}/SDK/samples/FirstFoundationClient/source/alfresco/extension (which I created because it was mentioned in the wiki documentation, but is missing) and another in SDK AlfrescoEmbedded/config!

I also ran into the cryptic "CreateProcess error=87" problem which is due to the classpath being too long - workaround is to move the SDK nearer to the root of the filesystem (e.g. C:\Alfresco) so that the paths are shorter (!).

melttech
Champ in-the-making
Champ in-the-making
Hi, i'm having problem to run FirstFoundationClient.java as Java application from Eclipse.

I have my alfresco working even before implementing this sample.

First, I added mysql-connector-java-5.1-22.bin.jar in my build path.

Second, i cant find alfresco-vti-4.0.d.jar, jetty-6.1.26.jar, jetty-util-6.1.26.jar in downloaded {alfresco-root}/SDK/lib/server directory

I already run my ant build.xml>Run as Ant build

Eclipse giving me org.springframework.jdbc.BadSqlGrammarException error

I bet theres sth to do with   ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();

Here is the error message : http://pastebin.com/cCQmMY2H

I'm thankful if someone can help me.

Cheers,

rjohnson
Star Contributor
Star Contributor
Your error suggests that your database schema and your Alfresco instance are out of step.

The default database is now Postgresql so I'm guessing that you elected to use MySql on the install instead or that you have upgraded from an earlier version.  I can't think of a reason why that would be a problem but…

Have you managed to log into Alfresco and do "some work" i.e. add, update and delete a document or 2?

melttech
Champ in-the-making
Champ in-the-making
HI,

Sry for late reply.

I'm using Mysql as database. My alfresco is working normally. I can do whatever i want in alfresco. I already copy paste alfresco-global.properties into Eclipse. This error driving me crazy

rjohnson
Star Contributor
Star Contributor
Then I suspect that the FirstFoundationClient is out of step with the 4.0d release database schema on MySQL. Looking at the log you put into PasteBin the key lines for me are

### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'node.node_deleted' in 'field list'
### The error may involve alfresco.node.select_NodeByNodeRef-Inline
### The error occurred while setting parameters
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'node.node_deleted' in 'field list'

To me, this says that the error is that FirstFoundationClient is trying to query your database and asking it to return information in a column node.node_deleted (so I'm guessing that means a table called node and a column within that table called node_deleted) and the issue is that this table / column combination isn't there.

Now, I am running 4.0a on postgresql and I have just had a quick look at my database structure using psql and I can tell you that there is no table called node, there is one called alf_node and there is one called avm_node and alf_node does have a column called node_deleted in it. I suggest that you have a peek at the MySQL database and see what tables you have got in it because it looks to me as if your SDK is trying to access a table that isn't there and based on the error message it looks as if the SQL statement created for MySQL is wrong.

Good luck and let me know how you get on.

Bob

melttech
Champ in-the-making
Champ in-the-making
I took a peek into mySQL and alf_node does not have a column called node_deleted in it.

What can go wrong?

rjohnson
Star Contributor
Star Contributor
Based on a very quick search of this forum it seems like you have a database from Alfresco V4.1 Schema 5113 or later and a development kit that pre-dates that because at V4.1 Schema 5113 the column node_deleted was removed from alf_nodes and replaced by another mechanism for tracking deleted nodes. See this JIRA

https://issues.alfresco.com/jira/browse/DOC-410?page=com.atlassian.jira.plugin.system.issuetabpanels...

I would start by checking to see if there is a later version of the SDK. If there isn't, ask a separate question in the relevant forum about when a new version might be available.

melttech
Champ in-the-making
Champ in-the-making
Thanks rjohnson for your help.

Appreciated it. Now it is clear the reason why i cant make the SDK running.

In the nutshell, available SDK wont work with Alfresco V4.1 Schema 5113 and later.

Cheers!