Monday, May 4, 2009

Setup Development Environment

My dream development environment consists of all open source tools:

  • Eclipse as IDE
  • Maven as build tool
  • Subversion as source code control
  • And an open source server: SpringSource dm Server

Recently there are many interesting announcements from SpringSource, like Spring dm Server 2.0M1, Spring Roo. I don't have time to follow those new trends, especially when they are just in alpha or beta stages. I want to focus on business application development and get my project done. So I just pick the released products from Open Source world, like dm Server 1.0.2.RELEASE.

I spent some time on BND and Maven Bundle Plugin, and tried to generate manifest from maven pom, but found it is too hard. SpringSource dm Server has an issue with Hibernate, you have to add "import-scope:=application" and put all bundles into a par file. See my questions at forum Where is the documentation about "import-scope:=application"?

Bundlor from SpringSource is also interesting, but I don't have time to learn another beta product, so I choose to manually create/maintain manifest files. Ideally I want to put all dependency info into pom, and derive manifest from pom. Maybe I will try again after Bundlor and dm Server 2.0 release after summer.

In order to continue my project, I just cleaned up my S2DM Maven plugin code and released 0.0.2. Open Toast Maven Plugin for SpringSource dm Server 0.0.2 has 2 goals now, one is to setup Eclipse config for OSGi projects, another is to generate par file. I code the plugin for Open Toast project, but it is generic enough for all Web application based on SpringSource dm Server. So feel free to use it and give me feedback.

Here is a brief description about how to setup environment for Open Toast Project:

1. Download and install Eclipse Ganymede SR2.

2. Install Subclipse eclipse plugin from http://subclipse.tigris.org/update_1.6.x

3. Install Spring IDE 2.2.2 and dm Server Tools 1.1.2 from http://www.springsource.org/update/e3.4. I have problem with dm Server Tools 1.1.3M1, but 1.1.2 seems very stable.

4. Download and unzip SpringSource dm Server 1.0.2.RELEASE, and set up a server runtime in Eclipse at localhost.

5. In Eclispe, open dm Server Repository Browser and download required dependencies:

  • Hibernate JPA Library 3.3.2.GA. It will include related bundles.
  • CGLIB 2.1.3. Not sure why it is not included in Hibernate library.
  • dbcp 1.2.2.osgi
  • commons.pool 1.4.0
  • hsqldb 1.8.0.9

6. Check out code from Google Code by any SVN client application, like TortoiseSVN, the url is http://opentoastproject.googlecode.com/svn/trunk/opentoast. You can also add svn repository for this url in Eclipse.

7. In command line, go to root directory of downloaded project, with parent pom.xml and 5 sub folders, run mvn org.opentoast:maven-s2dm-plugin:0.0.2:eclipse to set up eclipse config. Then import all projects into Eclipse. It may take a while to build those projects inside eclipse, and finally all compiler errors should be resolved.

8. In Eclipse, add org.opentoast.par into SpringSource dm Server v1.0 at localhost, and start the server. The console will display:

[2009-05-04 19:18:48.296] main                      Server starting.
[2009-05-04 19:18:49.365] main                      OSGi telnet console available on port 2401.
[2009-05-04 19:18:53.191] main                      Boot subsystems installed.
[2009-05-04 19:18:55.266] main                      Base subsystems installed.
[2009-05-04 19:18:57.053] server-dm-14              Installing profile 'web'.
[2009-05-04 19:18:58.737] server-dm-14              Installed profile 'web'.
[2009-05-04 19:18:58.944] server-dm-5               Creating HTTP/1.1 connector with scheme http on port 8080.
[2009-05-04 19:18:58.995] server-dm-5               Creating HTTP/1.1 connector with scheme https on port 8443.
[2009-05-04 19:18:59.028] server-dm-5               Creating AJP/1.3 connector with scheme http on port 8009.
[2009-05-04 19:18:59.072] server-dm-5               Starting ServletContainer.
[2009-05-04 19:18:59.892] server-dm-6               Server open for business with profile 'web'.
[2009-05-04 19:19:00.558] Deployer Recovery         Creating web application '/'.
[2009-05-04 19:19:00.936] async-delivery-thread-1   Starting web application '/'.
[2009-05-04 19:19:03.158] Deployer Recovery         Deployment of 'com.springsource.server.servlet.splash' version '1.0.2.RELEASE' completed.
[2009-05-04 19:19:03.526] Deployer Recovery         Creating web application '/admin'.
[2009-05-04 19:19:03.850] async-delivery-thread-1   Starting web application '/admin'.
[2009-05-04 19:19:04.377] Deployer Recovery         Deployment of 'com.springsource.server.servlet.admin' version '1.0.2.RELEASE' completed.
[2009-05-04 19:19:04.391] fs-watcher                Processing 'INITIAL' event for file 'server.admin.splash-1.0.2.RELEASE.jar'.
[2009-05-04 19:19:04.399] fs-watcher                File 'server.admin.splash-1.0.2.RELEASE.jar' already deployed.
[2009-05-04 19:19:04.404] fs-watcher                Processing 'INITIAL' event for file 'server.admin.web-1.0.2.RELEASE.jar'.
[2009-05-04 19:19:04.412] fs-watcher                File 'server.admin.web-1.0.2.RELEASE.jar' already deployed.
[2009-05-04 19:19:09.200] nection(2)-192.168.0.100  Creating web application '/opentoast'.
[2009-05-04 19:19:12.528] service-monitor-thread-1  Mandatory reference '&memberRepository' in bundle 'org.opentoast.par-0.0.1-org.opentoast.service' version '0.0.1' is waiting for service with filter '(&(objectClass=org.opentoast.domain.MemberRepository)(com.springsource.server.app.name=org.opentoast.par-0.0.1))'.
[2009-05-04 19:19:12.533] service-monitor-thread-1  Mandatory reference '&entityManagerFactory' in bundle 'org.opentoast.par-0.0.1-org.opentoast.service' version '0.0.1' is waiting for service with filter '(&(objectClass=javax.persistence.EntityManagerFactory)(com.springsource.server.app.name=org.opentoast.par-0.0.1))'.
[2009-05-04 19:19:12.830] server-dm-11              Reference '&entityManagerFactory' in bundle 'org.opentoast.par-0.0.1-org.opentoast.service' version '0.0.1' was satisfied by service with filter '(&(objectClass=javax.persistence.EntityManagerFactory)(com.springsource.server.app.name=org.opentoast.par-0.0.1))'.
[2009-05-04 19:19:12.837] server-dm-11              Reference '&memberRepository' in bundle 'org.opentoast.par-0.0.1-org.opentoast.service' version '0.0.1' was satisfied by service with filter '(&(objectClass=org.opentoast.domain.MemberRepository)(com.springsource.server.app.name=org.opentoast.par-0.0.1))'.
[2009-05-04 19:19:13.040] async-delivery-thread-1   Starting web application '/opentoast'.
[2009-05-04 19:19:13.769] nection(2)-192.168.0.100  Deployment of 'org.opentoast.par' version '0.0.1' completed.
If you open browser at http://localhost:8080/opentoast/home.htm, it will display current memebrs.

If you run mvn package, it will build final par file at org.opentoast.par/target/OpenToast.par. You can drop it under dm server pickup folder and start the server in command line. Of course, you have to add dependencies into springsource-dm-server-1.0.2.RELEASE\repository\bundles\usr folder before starting.

No comments: