Monday, May 12, 2008

creating a WebObjects application with Maven: WOProject, WOCreator, and WOLips

I'm starting a project working with WebObjects. I'm most familiar with
Tomcat, J2EE standards, and Ant/Maven, so let's see what it takes to get a working application.


A friend found posts referencing a different project WOCreator, and this one turned out to be very easy to install. Just follow the instructions on their main page. Here's what I ended up using (though I believe the 'repository' flag is wrong, but I suspect it's not being used in my case).

mvn \
-DgroupId=com.icentris.webdynamics -DprojectName=sampleCreator \
-Drepository=file:///home/trent/.m2/repository -DwebObjectsVersion=5.4

The one difficulty I had was with all the jars. First of all, you have to get the WebObjects jars into your repository; they provide a script that will install all the required jars into your local repository. This is incredibly helpful. Second, you have to manually install the following jars if you don't already have them; a quick web search will tell you where you can get them:
  • com.sun.jdmk jmxtools 1.2.1
  • com.sun.jmx jmxri 1.2.1
  • javax.jms jms 1.1
Quite frankly, after the struggles with WOProject, this is an awesome tool because it just works: you run the Maven tasks 'create-project', then 'package', then 'jetty:run-war'. The only thing that hung me up for a minute was the URL; Jetty started up and reported that I could go to the following URL:


However, this was wrong; I had to add the right port and change the context to the name I gave to 'create-project':


Wonderful! I have an application that I was able to tweak with 'webobject' tags and see something work. It only took about 24 hours because I started with WOProject first (see below). But start with WOCreator and you'll be working in no time.

WOProject bootstrap

It looks like the WOProject will install the jars and set up a sample app with Maven.

At first, I can't get the bootstrap to work:

[INFO] The plugin 'org.apache.maven.plugins:maven-wobootstrap-plugin' does not exist or no valid version could be found

I really struggled with this plugin stuff. The thing that finally seemed to get it to at least recognize the 'mdimension' repository was to create a dummy pom.xml and then add the plugin info to the 'reporting' section of a pom:


I then had to add the POM file directly to my local repo copy (to get around it's inability to find the org.apache.commons.lib.SystemUtil class):

... and I finally got something to work. Here's the final command:

mvn org.objectstyle.woproject.maven2:maven-wobootstrap-plugin:install \
-DwebObjectsLibFolder=/usr/local/apple/Library/WebObjects/lib -DwebObjectsVersion=5.4

That's frustrating, because I'm not quite sure what piece I added that made it all work. I spend about 6 hours fooling around with this stuff. Maybe I'll try and figure out this plugin craziness sometime.

Right now, I want to see if I can get the archetype setup to work.

WOProject archetype

I start with the following default from their example:

mvn archetype:generate -DarchetypeCatalog=local

It promps me to choose:

Choose archetype:
1: local -> woapplication-archetype (WebObjects Application Archetype)
Choose a number: (1):

... but the first time I got this error:

org.apache.maven.archetype.downloader.DownloadNotFoundException: Requested download does not exist.

Fine. So I try this, but it's totally wrong because it dies before I can even choose:

mvn org.objectstyle.woproject.maven2:archetype:generate \

And I graduate to a "FATAL ERROR" with this attempt:

mvn org.objectstyle.woproject.maven2:woapplication-archetype:generate \

At this point, I choose the first one again, and it seems to work because it prompts me for more and starts making the project. Argh! Is that good now that something's working, or bad because I have no idea what fixed it?

BTW, if you get the following error, make sure there's no pom.xml in the current directory:

[ERROR] org.apache.maven.archetype.exception.InvalidPackaging: Unable to add module to the current project as it is not of packaging type 'pom'

I learned I have to specify the "WebObjectsVersion" because it defaults to something else and doesn't ask you the first time around. (You could also answer "n" at the end of the other questions so that it prompts you for it, but then you have to answer all the questions again.) While I'm at it, I might as well specify it all.

So here's the final command:

mvn archetype:generate -DarchetypeCatalog=local -DWebObjectsVersion=5.4 \
-DgroupId=icentris-webdynamics -DartifactId=sample -Dversion=0.1 -Dpackage=app

Although this creates a basic app, the app doesn't build correctly with 'mvn package'. I tried a few things but it cannot find a properties file (that exists), and it says to run another buildfile (that doesn't exist):

org.objectstyle.woenvironment.env.WOBuildPropertiesNotFoundException: Could not find Run the buildfile: woproperties.xml first.

I've given up on this set of tools for now, mostly because I've found something else that works.


I have to mention WOLips: it claims to be "the toolset that Apple itself uses internally"; it certainly has great documentation (which I used to help with WOCreator above), and a colleague has successfully started porting his Mac-based development environment to WOLips so that the rest of us can play with it. Unfortunately, I followed their instructions to install with Eclipse Update Manager and I ended up with a project that has a bunch of errors and a directory structure that doesn't match their screen shots (and their proposed fixes don't remedy the situation). Well, that was a dead-end, but at least it was a quick one!

Update: I've got WOLips working, and fairly easily. I don't know what I did, but I erased all my earlier stuff and started with a new WO Application and I got something without any errors, and something that ran great when I right-clicked on and choose "Run As" a "WOApplication. This generates some build files for an Ant build process as well. If you have to work with a WebObjects application, I've heard that the UI is essential so you really have to use WOLips.

Thursday, May 8, 2008

installing FrontBase on Ubuntu (and/or Debian)

I got a grundle of problems attempting to install FrontBase, but my flailing attempts finally worked, so here's what happened.

Start with the official guide at the FrontBase site.

On my first 'dpkg' attempt, I got the following errors:

$ sudo dpkg -i FrontBase-4.2.8.deb
(Reading database ... 122351 files and directories currently installed.)
Preparing to replace frontbase 4.2.8-1 (using FrontBase-4.2.8.deb) ...
Unpacking replacement frontbase ...
dpkg: dependency problems prevent configuration of frontbase:
frontbase depends on libncurses4 (>= 4.2-3.1); however:
Package libncurses4 is not installed.
frontbase depends on libreadline4 (>= 4.1); however:
Package libreadline4 is not installed.
dpkg: error processing frontbase (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:

Then I tried 'apt-get' and still got errors:

$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
libncurses4 libreadline4
The following NEW packages will be installed:
libncurses4 libreadline4
0 upgraded, 2 newly installed, 0 to remove and 18 not upgraded.
1 not fully installed or removed.
Need to get 298kB of archives.
After unpacking 709kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 gutsy/universe libncurses4 4.2-10.1 [194kB]
Get:2 edgy/universe libreadline4 4.3-18 [104kB]
Fetched 298kB in 2s (131kB/s)
Selecting previously deselected package libncurses4.
(Reading database ... 122351 files and directories currently installed.)
Unpacking libncurses4 (from .../libncurses4_4.2-10.1_i386.deb) ...
Selecting previously deselected package libreadline4.
Unpacking libreadline4 (from .../libreadline4_4.3-18_i386.deb) ...
Setting up libncurses4 (4.2-10.1) ...

Setting up libreadline4 (4.3-18) ...

Setting up frontbase (4.2.8-1) ...
Starting FrontBase service

Processing triggers for libc6 ...
ldconfig deferred processing now taking place

Well, it looks like something happened, so I tried 'dpkg' again and got something a bit different:

$ sudo dpkg -i FrontBase-4.2.8.deb
(Reading database ... 122374 files and directories currently installed.)
Preparing to replace frontbase 4.2.8-1 (using FrontBase-4.2.8.deb) ...
Shutting down FrontBase service
/var/lib/dpkg/info/frontbase.prerm: 11: /etc/init.d/FBWeb: not found
dpkg: warning - old pre-removal script returned error exit status 127
dpkg - trying script from the new package instead ...
/var/lib/dpkg/ 11: /etc/init.d/FBWeb: not found
dpkg: error processing FrontBase-4.2.8.deb (--install):
subprocess new pre-removal script returned error exit status 127
Starting FrontBase service
Errors were encountered while processing:

Even though it still complains of errors, I tried looking at my processes, and viola:

$ ps -edalf | grep FrontBase
0 S root 24174 1 0 75 0 - 1335 - 13:09 pts/4 00:00:00 /usr/lib/FrontBase/bin/FBExec -autostart

Then I ran through the example statements on the install page via sql92 and saw the first DB running:

$ ps -edalf | grep FrontBase
0 S root 24174 1 0 75 0 - 1335 - 13:09 pts/4 00:00:00 /usr/lib/FrontBase/bin/FBExec -autostart
0 S root 24248 1 0 75 0 - 4392 - 13:13 pts/4 00:00:00 /usr/lib/FrontBase/bin/FrontBase /usr/lib/FrontBase/Databases/firstdb.fb

Great! Now I can even connect with my Java SQL tool using the FrontBase driver with the following info:
  • URL: jdbc:FrontBase://localhost/firstdb
  • User: test
  • Pass: