Tuesday, November 04, 2008

How to use custom ant tasks in a WTP generic ant publisher

Before creating the Eclipse Pluto Server Plug-in, I had an Ant script to publish my portlets to a Pluto server. That Ant script used the Maven2 ant tasks to download the needed Pluto ant task jar and its dependencies. This Pluto ant task is needed to rewrite the portlet's web.xml so that it contains the Pluto server's invoker of the portlet. When I first created the plug-in and needed a way to get the Pluto ant task jar, I looked for how to include it with the plug-in jar but I couldn't figure out how to expose it to the Pluto ant publisher script I created as part of the WTP generic server definition. So, I used the Maven2 stuff I already had, and it worked pretty well for me. However, it was never ideal.

Recently, actually by accident, I figured out how to make ant tasks in a plug-in available to a WTP ant publisher. I stumbled upon the Eclipse ant extension point documentation, specifically, the part about Extra Ant Classpath Entries. Not sure how I missed this before, but it's basically all right there. There's also the org.eclipse.ant.core.antTasks extension point which allows you to expose ant tasks to your ant scripts in Eclipse. Since it wasn't immediately obvious to me at first, I thought I would post how I got it working. It's actually quite simple once you know what extension points to work with.

Here's what I added to the Pluto Server Plug-in plugin.xml to define the Pluto ant task

<extension point="org.eclipse.ant.core.antTasks">
<antTask name="pluto.assemble"

But of course this ant task has dependencies. To make it's dependencies available to it, you'll just need to add extraClasspathEntries

<extraClasspathEntries library="lib/castor-1.1.1.jar" eclipseRuntime="false" />
<extraClasspathEntries library="lib/cglib-full-2.0.2.jar" eclipseRuntime="false" />
<extraClasspathEntries library="lib/commons-beanutils-1.7.0.jar" eclipseRuntime="false" />
<extraClasspathEntries library="lib/commons-cli-1.0.jar" eclipseRuntime="false" />
<extraClasspathEntries library="lib/commons-digester-1.8.jar" eclipseRuntime="false" />
<extraClasspathEntries library="lib/commons-io-1.3.1.jar" eclipseRuntime="false" />
<extraClasspathEntries library="lib/commons-lang-1.0.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/commons-logging-1.0.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/commons-logging-api-1.1.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/pluto-descriptor-api-1.1.6.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/pluto-descriptor-impl-1.1.6.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/pluto-util-1.1.6.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/xercesImpl-2.6.2.jar" eclipseRuntime="false"/>
<extraClasspathEntries library="lib/xmlParserAPIs-2.6.2.jar" eclipseRuntime="false"/>

I'm not quite sure why, but the eclipseRuntime attribute needs to be set to false to get this to work. The docs say

eclipseRuntime - indicates whether this extra classpath entry should only be considered for builds run in the same VM as Eclipse. The implied value is true, when not specified.

So I can only guess that this means that the WTP ant publisher doesn't run in the same VM as Eclipse? Anyhow, I tried it both ways, and it only worked with the value of false.

From my ant publisher script, nothing special, I just reference the pluto.assemble task (I gave it that name). Here's the snippet where I use it:

<target name="assemble" if="portletxml.exists">

<pluto.assemble webxml="${module.dir}/WEB-INF/web.xml"
destfile="${webxml.with.portlet.mapping.file}" />

Previously I had to define the task with a <taskdef> tag, but I no longer need that.

Pluto Server Plug-in 1st beta of 1.0.0 released

This past weekend I created a 1.0.0.b1 release of the Eclipse Pluto Server Plug-in. Biggest change is that I got rid of the hack I had in there using Maven to download the Pluto ant task and dependencies needed to publish a portlet to Pluto. I now bundle the ant task jar and its dependencies with the plug-in (a topic for a future post). Having Maven do the download was something that would work most times but had problems. For example, some users have not been able to get the plug-in to work with a proxy server setup (see issue #3).

It likely won't get picked up as an update in Eclipse; you'll need to go into the Update Manager and install it as a new feature. And don't forget to use http://pluto-server-plugin.googlecode.com/svn/trunk/pluto.server.update as your update site. If you try it out, let me know. I'd like to make the 1.0.0 release soon.

Saturday, August 02, 2008

Could not publish to server NPE bug fixed!

I finally had some time to sit down and try to figure out the "Could not publish to server NPE bug". Turns out to be a bug in WTP 2.0.2, bug #219627. The WTP team released a patch and then later they made a full 2.0.3 release. However, if you download the latest version of Eclipse Europa (for JEE), it still has the older 2.0.2 version of WTP. Which I believe explains why there have been so many reports of this problem.

So the fix is to run the update manager in Eclipse and get the most recent updates for WTP. I confirmed this by reverting my Eclipse config to WTP 2.0.2 and was able to reliably reproduce the issue. Reverting back to WTP 2.0.3 got the deploy to Pluto working again.

I added a FAQ page for the project with a FAQ also explaining the issue. I also verified that the Pluto server plug-in works in Ganymede.

Many thanks to campi, by the way. I basically ran a Google search based on the stack trace campi posted to find others who had run into the same issue but with a different plug-in. And that eventually got me to the Eclipse bug and the resolution.

Monday, June 30, 2008

Amazon Unbox Review

Synopsis: Amazon Unbox is too lacking in the convenience and features departments to justify the price. But if they address some of the missing features and switched to a Netflix-style, all-you-can-eat subscription model, then they could really compete.

Recently had an excuse to try out Amazon Unbox on our Tivo. The whole family was sick this past weekend and we had already watched our Netflix movie and everything Tivo had recorded for us :) So we thought, why not download a movie from Amazon Unbox?

I had already linked my Amazon account with our Tivo account, so ordering the movie just required that I enter a 5 digit pin number. There was a snafu with the credit card I was using, but once I got that resolved, the movie started downloading almost immediately. Only problem was that it took a LOOOONNNNGGGG time for it to download (we have a supposedly 10mbps cable DSL connection). By long, I mean in the range of about 6-8 hours. Since we started this just before dinner, there was no chance we could watch this that night. We had to wait until the next day.

The movie shows up in the Now Playing list as soon as it starts downloading. There is no estimate of how long it will take to complete, but Tivo does tell you how many minutes of the movie have been downloaded. The Amazon Unbox site doesn't tell you how many minutes total the movie is, but I was able to find this information via Netflix. Thus, you can do back of the envelope calculation of how long the download will take. (By the way, I believe the total download size was 2.4 GB).

The way Amazon Unbox works is that you have 24 days to keep the downloaded rental, but once you start watching it, you have 24 hours before it will be deleted. Tivo's provides a warning message when you start watching the movie and if you stop watching Tivo tells you exactly when the movie will be deleted. So that's all very good.

We started watching the movie, and the picture quality is top notch, easily DVD quality. It's just like a recorded TV program; there are no chapters, no menus, just the movie from beginning to end. So that's one strike against Amazon Unbox, that you don't get the bonus features or options or navigability of a DVD. Since the characters in this particular movie speak with a Scottish accent, we wanted to put on subtitles. Nope, can't do it. How about closed captioning? Amazingly, no, closed captioning doesn't work either. This is pretty much a deal breaker for me.

The movie cost $3.99, about the same as rental from a local video store. Is the value worth the price? No, I don't think so. Speaking of the local video store, it would have been faster to have walked to it to rent a DVD, and we would have had a richer viewing experience on top of it, for about the same price. And it can't begin to compete with the tremendous value of the Netflix service.

I have some advice for the Amazon Unbox team (they're waiting with bated breath for it, I know). They really need to add support for closed captioning, at the very least, but if they could figure out a way to add in the other features that one typically expects with a DVD that would definitely bolster their offering. The long download time could be mitigated if the download occurred automatically, in the background. What I'm thinking of here is a subscription service and that one could have a Netflix like queue with their Amazon Unbox account and when they finish with one movie and delete it, the next movie could start downloading immediately. This would mean a turnaround time measured in hours instead of the Netflix turnaround time which is measured in days.

Saturday, June 28, 2008

Getting open square bullets in OpenOffice.org

Sometimes it's nice to create a bulleted list with a check box like bullet, e.g., creating a packing list. Seems like in Word there's a quick option for selecting this style of bullets, but not so in OpenOffice. To change a bulleted list to have a check box style bullet:
  1. Select the bulleted list and in the menu go to Format > Bullets and Numbering...
  2. In the dialog that comes up, select the Options tab.
  3. Click the ... button labeled Character. Under Ubuntu, the default font for my document is DejaVu Sans and the subset of characters displayed is the Geometric Shapes. If you scroll up or down a bit, you can see a few different open square type bullets that can be used as check boxes.

Sunday, June 22, 2008

Eclipse Pluto Server Plug-in, v. 0.2.5 (now on Google Code)

Just finished moving the Pluto Server Plug-in code over to its own project page, pluto-server-plugin, on Google Code. I created a new minor release, v. 0.2.5, just to switch over the update site to the one on Google Code. Switching over a plug-in's update site took some experimentation, but here's how I did it (for future reference and for anyone else needing to change a plug-in's update site)
  1. Change the Update Site URL for the Feature to the new update site.
  2. Bump the Feature version and do a new release to the old site. Users with an older release of the plug-in will get the update which will point them to the new update site for future releases.
  3. Change the Update Site URL in the Update Site's site.xml file. Publish the update site to the new update site location.
So hopefully it will be a seamless update for Pluto Server Plug-in users.

Sunday, June 01, 2008

Pluto Server Plug-in: Could not publish to server NPE bug

Some users of the Pluto server plug-in have had trouble getting a simple plug-in to deploy. They receive an error message:
Could not publish to the server.

Unfortunately, I've not been able to recreate the "Could not publish to the server" error. I have created a new, clean Eclipse workspace and install, and went through the tutorial and it all still works.

For those who are experiencing problems, I've added a test portlet eclipse project that you can import and try to deploy to Pluto. Some other troubleshooting ideas
  • Make sure that you have a portlet.xml along with your portlet code. That will be necessary. See the eclipse project above for a simple example.
  • When first doing the deploy, you'll need to be connected to the internet so that the Maven ant tasks can download the pluto dependencies. This is only required the first time you use the plug-in to deploy to a pluto server.
  • Check ECLIPSE_WORKSPACE/.metadata/.log. It may have more details regarding the exact nature of the error. If you find anything, please do share it with me; I'd love to get to the bottom of this bug.
In other Pluto Server Plug-in related business, I hope to have the code moved over to Google Code sometime this month.