Archive for November, 2008

Running Shindig on your Mac

If you run a social network, you really owe it to your users to investigate OpenSocial as a way of allowing your users to add third-party functionality to their profiles. Shindig (available in a PHP and a Java version) allows you to easily add this capability.

Mac OS X Leopard has Java 1.6 and Maven 2.0.6 installed. I had some build issues with the older Maven so I upgraded to 2.0.9. You also need to ensure that your JAVA_HOME variable is set. You can confirm this by typing the following commands in a terminal:

Trinity:shindig kelvin$ echo $JAVA_HOME
/Library/Java/Home
Trinity:shindig kelvin$ mvn -v
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "mac os x" version: "10.5.5" arch: "x86_64" Family: "mac"

Then download the code from the main repository:

Trinity:code kelvin$ mkdir shindig
Trinity:code kelvin$ svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/ ./shindig
A    shindig/NOTICE
A    shindig/java
A    shindig/java/social-api
A    shindig/java/social-api/src
A    shindig/java/social-api/src/test

...la dee da...

A    shindig/features/mocks/env.js
A    shindig/features/mocks/xhr.js
 U   shindig
Checked out revision 707938.

Okay, Shindig has now been downloaded. Let’s build it. You can try building it using ‘mvn clean install’ first and if you get any errors, try turning off the tests. Sometimes the tests can get out of sync with the code. I was able to build it without any problems.

Trinity:shindig kelvin$ mvn clean install
[INFO] Scanning for projects...
[INFO] Reactor build order: 
[INFO]   Apache Shindig Project
[INFO]   Apache Shindig Project Parent
[INFO]   Apache Shindig Common Code
[INFO]   Apache Shindig Gadget Renderer
[INFO]   Apache Shindig Social API
[INFO]   Apache Shindig Features
[INFO]   Apache Shindig Web App
[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Shindig Project
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean]
[INFO] Deleting directory /Users/kelvin/code/shindig/target
[INFO] [site:attach-descriptor]

...etc etc etc...

[INFO] [install:install]
[INFO] Installing /Users/kelvin/code/shindig/java/server/target/shindig-server-1-SNAPSHOT.war to /Users/kelvin/.m2/repository/org/apache/shindig/shindig-server/1-SNAPSHOT/shindig-server-1-SNAPSHOT.war
[INFO] Installing /Users/kelvin/code/shindig/java/server/target/shindig-server-1-SNAPSHOT-sources.jar to /Users/kelvin/.m2/repository/org/apache/shindig/shindig-server/1-SNAPSHOT/shindig-server-1-SNAPSHOT-sources.jar
[INFO] 
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Apache Shindig Project ................................ SUCCESS [6.196s]
[INFO] Apache Shindig Project Parent ......................... SUCCESS [0.531s]
[INFO] Apache Shindig Common Code ............................ SUCCESS [9.470s]
[INFO] Apache Shindig Gadget Renderer ........................ SUCCESS [25.571s]
[INFO] Apache Shindig Social API ............................. SUCCESS [11.381s]
[INFO] Apache Shindig Features ............................... SUCCESS [7.117s]
[INFO] Apache Shindig Web App ................................ SUCCESS [13.737s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 14 seconds
[INFO] Finished at: Sun Nov 09 10:43:56 PST 2008
[INFO] Final Memory: 51M/80M
[INFO] ------------------------------------------------------------------------

or if you want to skip the tests, try this…

Trinity:shindig kelvin$ mvn clean install -Dmaven.test.skip=true

Woot. Now let’s start it up. By default, the server will run on localhost port 8080.

Trinity:shindig kelvin$ mvn -Prun
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'jetty'.
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.pom
1K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugin-parent/2.0.1/maven-plugin-parent-2.0.1.pom
7K downloaded
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.jar
11K downloaded
[INFO] ------------------------------------------------------------------------
[INFO] Building Apache Shindig Project
[INFO]    task-segment: [jetty:run-war]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jetty:run-war


...more more more...

[INFO] Starting jetty 6.1.9 ...
2008-11-09 10:47:45.790::INFO:  jetty-6.1.9
2008-11-09 10:47:45.812::INFO:  Extract jar:file:/Users/kelvin/code/shindig/java/server/target/shindig-server-1-SNAPSHOT.war!/ to /Users/kelvin/code/shindig/target/work/webapp
2008-11-09 10:47:47.372::INFO:  No Transaction manager found - if your webapp requires one, please configure one.
Nov 9, 2008 10:47:48 AM org.apache.shindig.common.JsonContainerConfig loadContainers
INFO: Loading resources from: containers/default/container.js
Nov 9, 2008 10:47:48 AM org.apache.shindig.common.JsonContainerConfig loadResources
INFO: Reading container config: containers/default/container.js
2008-11-09 10:47:48.313::INFO:  Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server

See if you can render anything by opening a web browser and putting the following into the address bar.

http://localhost:8080/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml

If all went well, you should see the To Do list demo.

The To Do Shindig App

The To Do Shindig App

Tags: , ,

Upgrade your Maven on OS X Leopard

As of Mac OS X 10.5.5, Java is now up to 1.6 and Maven comes pre-installed at version 2.0.6. We’re going to upgrade Maven to the latest version 2.0.9. Check your versions!

Trinity:~ kelvin$ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
Trinity:~ kelvin$ which mvn
/usr/bin/mvn
Trinity:~ kelvin$ /usr/bin/mvn -v
Maven version: 2.0.6
Trinity:~ kelvin$ 
Trinity:~ kelvin$ 

Visit the Maven web site and download the latest version (currently 2.0.9). It downloads to the Download folder, so you will have to move it. I installed Maven to /usr/local/apache-maven

Trinity:~ kelvin$ sudo sh
Password:
sh-3.2# cd /usr/local
sh-3.2# wget http://gulus.USherbrooke.ca/pub/appl/apache/maven/binaries/apache-maven-2.0.9-bin.zip
--2008-11-09 01:34:39--  http://gulus.usherbrooke.ca/pub/appl/apache/maven/binaries/apache-maven-2.0.9-bin.zip
Resolving gulus.usherbrooke.ca... 206.167.141.10
Connecting to gulus.usherbrooke.ca|206.167.141.10|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2025041 (1.9M) [application/zip]
Saving to: `apache-maven-2.0.9-bin.zip'

100%[======================================================================================>] 2,025,041    456K/s   in 5.1s    

2008-11-09 01:34:45 (389 KB/s) - `apache-maven-2.0.9-bin.zip' saved [2025041/2025041]

sh-3.2# md5 apache-maven-2.0.9-bin.zip 
MD5 (apache-maven-2.0.9-bin.zip) = 5e92d1c5b0a6580127059e28fe2f2b45
sh-3.2# unzip apache-maven-2.0.9-bin.zip 
Archive:  apache-maven-2.0.9-bin.zip
   creating: apache-maven-2.0.9/
   creating: apache-maven-2.0.9/conf/
  inflating: apache-maven-2.0.9/LICENSE.txt  
  inflating: apache-maven-2.0.9/NOTICE.txt  
  inflating: apache-maven-2.0.9/README.txt  
   creating: apache-maven-2.0.9/bin/
  inflating: apache-maven-2.0.9/bin/m2.bat  
  inflating: apache-maven-2.0.9/bin/m2.conf  
  inflating: apache-maven-2.0.9/bin/mvn.bat  
  inflating: apache-maven-2.0.9/bin/mvnDebug.bat  
  inflating: apache-maven-2.0.9/bin/m2  
  inflating: apache-maven-2.0.9/bin/mvn  
  inflating: apache-maven-2.0.9/bin/mvnDebug  
  inflating: apache-maven-2.0.9/conf/settings.xml  
   creating: apache-maven-2.0.9/lib/
  inflating: apache-maven-2.0.9/lib/maven-2.0.9-uber.jar  
   creating: apache-maven-2.0.9/boot/
  inflating: apache-maven-2.0.9/boot/classworlds-1.1.jar  
sh-3.2# exit
Trinity:~ kelvin$

The Maven installation instructions call for the creation of the M2 environment variables, so we need to do that. I put them into the .bash_profile file which is in your home directory.

export M2_HOME=/usr/local/apache-maven-2.0.9
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

Put these somewhere near the top of your .bash_profile file so that the shell will find the mvn 2.0.9 version before it finds the old 2.0.6 version at /usr/bin/mvn.

Trinity:~ kelvin$ source .bash_profile
Trinity:~ kelvin$ mvn -v
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "mac os x" version: "10.5.5" arch: "x86_64" Family: "mac"
Trinity:~ kelvin$ echo $M2_HOME
/usr/local/apache-maven-2.0.9
Trinity:~ kelvin$ which mvn
/usr/local/apache-maven-2.0.9/bin/mvn
Trinity:~ kelvin$ 

Tags: