Archive for the 'java' Category

Apache OFBiz Development (book review)

Book cover
Apache OFBiz Development: The Beginner’s Tutorial, by Jonathon Wong and Rupert Howell, aims to fill a niche that was completely empty until this book was published. The Apache OFBiz project is an Open Source framework for building enterprise automation applications on the Java platform. OFBiz has been used to build many business applications, but until now there wasn’t a comprehensive beginner’s tutorial for developers wanting to use the platform. As with many Open Source projects, freely available OFBiz documentation tends to be incomplete and not very well organized, so a book that can be read cover-to-cover and provides a good developer’s tutorial is certainly welcome.

Unfortunately, this book fulfills this promise only partially. As a disclaimer, let me start by saying that I am not an OFBiz expert, having only had a passing acquaintance with its Persistence Engine, so I am not equipped to judge whether the content of this book is accurate and reasonably complete. I am indeed a beginner with respect to OFBiz, so I should be exactly the right kind of public for this book.

As the beginner that I am, I started reading the book, but soon found it very hard to keep on reading. For one thing, the text does not seem to follow a smooth, linear narrative. Its flow is continuously broken up by the use of very short sections with a big, bold title. Personally, I’d have saved on the ink and paper and coalesced small sections into bigger ones.

Another problem, at least in the early chapters, is the tendency to present simple concepts and examples, together with a promise to explain more in the rest of the chapters. I understand that you cannot present very detailed explanations right at the beginning, but this book goes just a bit overboard in leaving the reader hanging on.

The net effect of this approach is that it makes reading very difficult, after a while. This problem could be overcome by a reader with enough patience and determination, but in my case I soon started to skip sections and to peek ahead to see if there was something more interesting for me.

Sampling around, I came upon Chapter 9, “The Events” and was very perplexed. This s a short chapter which only uses the “event” word twice in the first page, without even explaining what an event is in the context of OFBiz, copies some text from page 117, then switches completely to the topics of security and access control, and of localization, none of which seems particularly event-driven to me. Maybe I am completely missing the meaning of “event” in OFBiz, but this is just one more reason to explain it properly in a beginner’s tutorial.

Another aspect of the book that I was uncomfortable with is that, most of the time, the reader is treated not just as an absolute beginner with OFBiz, but as a beginner with the whole concept of developing Java web applications, to the point of showing him how to download and install the JDK. I would just state that a certain level of knowledge and past experience with the whole platform is a requirement in the preface. Showing how to install the JDK is not going to help anyone here.

To sum it up, my opinion of this book is not very good. Still, all is not bad, and I think it can be a decent tutorial for most parts of OFBiz. Since such a tutorial was definitely needed, it’s a shame “Apache OFBiz Development” succeeds only partially.

Update: “Chapter 10: the Service Engine” is freely available from the publisher’s website.

(5)

Scarlet

Kudos to my colleagues Ugo and Sergio for releasing Scarlet:

Sourcesense is proud to announce the first beta of Scarlet, a clustering solution for Atlassian Jira bringing high-availability and scalability to the award-winning Jira issue tracker. The solution is based on Terracotta DSO, the Open Source clustering framework from Terracotta, enabling easy and trasparent scalable Java solutions.

Scarlet provides a full-fledged clustering solution for Jira, bridging an important gap when it comes to enterprise architectures based on high-availability: rated as one of the most popular requests from Jira users, clustering support makes Jira a truly distributed enterprise-class solution for organizations relying on simple yet effective scalable architectures.

Scarlet is distributed as an Open Source extension to Jira under the Mozilla Public License 1.1 and it’s available from http://confluence.atlassian.com/x/woQuBg. Jira users and developers are encouraged to dowload the extension and provide feedback: Sourcesense is committed to support and manage contributions, under a transparent and meritocratic Open Development process. Commercial support and additional services are available from http://www.sourcesense.com.

One of the interesting facts about Scarlet is the fact that it’s based on Terracotta DSO, an insanely cool distributed object system, network-attached memory, or what you call it, and Open Source to boot. Ever since I first heard about it, I was under the impression that it could be a great solution to a large class of problems, but was never able to personally verify this assumption. With Scarlet we have a great example of its validity.

JRuby 1.0 Released!

Charles Nutter: “We have finally released JRuby 1.0, based on the last release candidate, RC3. And what more is there to say? Not really a whole lot…It’s almost entirely RC3, with one or two minor fixes added in. But it’s really turned out to be an outstanding release, and already reports are coming in of folks trying it out en masse. We’re very happy.”

Congrats!

Lucene GdataServer

GdataServer – Lucene-java Wiki: “GData-Server is a lucene sandbox project started in June 2006. The first 2 1/2 month of the project this has been a one man show due to Google’s SummerOfCode. In fact of that the server is still in high development status but offers all features described in the GData protocol. Generally speaking, the Lucene GData Server is an extensible syndication format server providing CRUD actions to alter feed content, authenticaton, optimistic concurrency and full text search based on Apache Lucene.”

Nice!

Who Cares About Sun Open-Sourcing Java?

James Gosling: “There are real wars. And it’s really hard to be friendly to the open-source community because if you’re friendly to this camp then you’re viewed as an enemy by that camp. And one of the things we got stuck on was that we really like the Apache folks, but we also rather liked the GPL guys. And the Apache folks were very angry at us for picking GPL. But we had to pick something. If we’d picked the Apache license, the GPL crowd would be upset with us.”

I’m with Geir on this one: Sun could be friendly to everyone. It’s not like “the enemy of my enemy is my friend”. Moreover, painting the relationship between the ASF and FSF as a kind of war is a bit over the top, isn’t it?

Gosling confirms again that he’s not particularly smart when talking about Open Source, as already mentioned here and here. However I’m happy to learn that he changed his stance from this:

We’ve got several thousand man-years of engineering in [Java], and we hear very strongly that if this thing turned into an open source project—where just any old person could check in stuff—they’d all freak. They’d all go screaming into the hills.

to this:

But it feels like we’ve gotten to a point where the developer community is strong enough and feels strongly enough about consistency and interoperability and quality that market pressures will keep things on track. And those that try to misbehave will have issues with the market.

even though it took almost exactly two years.

Introducing Buildr

Assaf Arkin: “That, in a nutshell, is how we went from the deeps of frustration to a build system that … hold on a second … is actually fun to use. And dead easy to customize. And works repeatedly.”

I don’t hate Maven with the same passion as Assaf has, but that’s probably only I haven’t yet used Maven in anger for a big project. My latest big project started with Maven, but moved quickly to Ant+Ivy.

Still, Ant is not at all fun to use. I find most of our Ant scripts unreadable (pointy brackets don’t help) and the maze of includes that were put in place to provide some kind of code reuse too confusing and impossible to debug.

Mind you, this is not an indictment of the fine people who wrote those scripts. They did the best job possible, given the limitations of the tool.

Anyway, neither Ant nor Maven seem to be any fun to use, so I’d welcome anything that promises to bring back some fun to the process. We all know that writing stuff in Ruby can be fun—again—but my worry is that adopting a build system that nobody else uses is bound to give you problems, like not being able to find people who are already expert with your tool of choice.

However, if nobody ever tried anything different, we’d be stuck with make, I think.

(Via Tim Bray.)

Jonas Boner @ Jug Milano – January 18th

Jonas_BW_160x160.jpgAs anticipated some weeks ago, Jonas Boner will be our special speaker at the 22nd meeting of the Java Uesr Group Milano, on January 18th at 6.45pm.

Jonas is a well known speaker, architect and open source developer, founder of the AspectWerkz project and committer of AspectJ. He’s Senior Software Engineer at Terracotta.

The title of his talk will be Distributed Computing Made Easy: How To Build a POJO-based Data Grid:

Abstract
In this session you will learn how to build a highly scalable Data Grid using standard JDK 1.5 and POJOs.
We will start with a discussion of the Master/Worker pattern — one of the most useful parallel programming design patterns in use today. You will learn about the identifying characteristics of the pattern and how best to use it in the real world.
It is a very practical, “hands-on” session in which we will present how to build the Master/Worker pattern using standard JDK 1.5, and how to turn it into a distributed grid implementation by using Open Terracotta’s* JVM-level clustering technology. Following that, we will cover the production implications of operating and scaling a reliable work management framework, and give examples on how to address real-world challenges such as dealing with very high volumes of data, handling work or worker failure, ordering, routing schemes etc.

Check out this page for all the details about the meeting.

Via Filippo.

The eBay Architecture

logoEbay_150x70.gifAs a Java architect, I’ve always been curious to learn about what makes large, enterprise Java systems tick. One of the biggest Java systems out there is certainly eBay, and if you want to know more about its architecture, now you can read the slides of an SDForum presentation titled “The eBay Architecture – Striking a balance between site stability, feature velocity, performance and cost”.

Attending the live talk would have been great, but even form the slides only (PDF version here), there are many important lessons in there, particularly regarding scalability. Some of them are nuggets of often repeated wisdom, like “Keep application tier completely stateless” and “Cache where possible”. Others are more unexpected, like:

  • Throw out most of J2EE, and
  • No business logic in database (no stored procedures and only very simple triggers).

All in all, a very good read.

Releases!

Old news, I know, but I just want to underline how some of these releases tie together, possibly to indicate an important trend.

First of all, we have Java SE 6, with Javascript built-in, thanks to Mozilla Rhino.

Then we have JRuby 0.9.2, with a slew of enhancements, bug fixes and performance tweaks.

Finally, after a long wait, Groovy RC-1.

All signs pointing to 2007 as the year of dynamic languages on the Java platform? It really seems likely.

On an unrelated note, I am also pleased to announce the relase of Apache Abdera 0.2.0 (incubating). Nothing revolutionary here, but an impressive number of features already for a 0.2 version. Very stable and surprisingly bug-free also.

And GPL it is

In the end all rumors have been confirmed and today will mark the day when Java source code has been opened, under the GPLv2. Details to follow at www.sun.com/opensource/java, where a live webcast with Jonathan Schwartz and Rich Green will be held at 9:30AM PT (that is 6:30PM CET, so it means I will probably be traveling at that time).

With respect to the fears I have expressed about the core libraries being GPL as well, it looks like—according to Tim Bray— that they will use the Classpath Exception clause to avoid code using them to be infected by the GPL. I can’t even begin to wonder what the actual legal consequences of this are, but the spirit—if not the wording— of the clause seem pretty clear to me.

Technorati Tags: , , , , , , .

Straight from the horse’s mouth

Simon Phipps.jpgSo it looks like Sun might decide to license Java SE and ME under the GPL. I sure hope that doesn’t include the core libraries, otherwise once your code does something trivial like implements java.io.Serializable it will be GPLed as well, and the LGPL is not going to be safer in this respect.

In any case, if you want to hear the story directly from the man who is overseeing this, i.e. none other than Sun’s Chief Open Source Officer Simon Phipps, you’d better join us at the Open Source Business Academy, where Simon will deliver another one of his Zen of Free talks, this time aptly subtitled “The Philosophy behind the Open Sourcing of Java”. What better occasion than this one to get answers to this one and many other questions about Sun, Java and Open Source?

Technorati Tags: , , , , .

Spring 2.0 released

Today marks an important milestone, as the Spring Framework 2.0 has finally been released, after a long period of beta testing.

What I expect from it is a mostly painless upgrade of several projects I have running on Spring 1.2 and the usual commitment to quality and excellence. As far as new features are concerned, I’ve got at least one good use case for scoping beans to an HTTP request. The other new features can be adopted gradually.

Spring rocks!

Technorati Tags: , .

Re: Outsourcing the performance-intensive functions

While I’m waiting to board my (delayed, once again) flight to London, I am doing some blog surfing and just came upon this quote from DHH:

“The era of islands is over for most development scenarios. You don’t have to make one definitive choice. Instead, you get to hog all the productivity you can for the common cases, then outsource the bottlenecks to existing packages in faster languages or build your own tiny extension when it’s needed.”

Well, the era of islands did never actually begin for pragmatic developers, to be honest, but anyway I think this sentence, and all of David’s piece, could very well be taken as an endorsement of the work I’ve been doing: investigating the integration between the Ruby and Java worlds.

I like is so much that I’ve just added a slide with the above sentence to my presentation for tomorrow.

And no, I don’t even want to touch the “language wars” thread with a pole. Use the right tool for the job and to each his own.

No joy with camping on JRuby

camping.pngWednesday I’m flying to London, where I’ll be speaking at the European Rails conference. I’ll be presenting on the same subject I did at OSCON: Ruby for Java Programmers.

At OSCON I demoed installing and running Rails on JRuby during the second half of the talk, but for EuroRails I’m trying to think of something different, mostly because I don’t want to steal the scene from Charles, who will be demoing exactly that. My backup plan involves demoing an installation of camping, following Ola Bini’s tutorial.

I’m not sure it’s a good idea to talk at a Rails conference about something else than Rails. In any case, I’m not even sure I can make it, since I cannot even get camping to install using either JRuby 0.9.0 or the latest code from svn:

Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR:  While executing gem ... (NoMethodError)
    undefined method `rubygems_version' for 0.9.7:Gem::Version

I’ve opened a new issue about this, but I doubt it’ll get fixed by tomorrow. So I probably need to find a backup plan to my backup plan.

Rails 1.1.4 Should Run Unmodified in JRuby

Charles Nutter: “Now, with the release of 1.1.4, the following will all work out-of-the-box with JRuby 0.9.0 (currently in RC status):”

gem install rails --include-dependencies

Check

# and use --no-rdoc for now...it's too slow

Check, even though it insisted on building documentation and yes, it was slow, but it finished eventually.

rails ~/myapp
lib/ruby/gems/1.8/gems/rails-1.1.4/bin/../lib/rails_generator/options.rb:33:
        in `method_missing': undefined method `write_inheritable_attribute' for
Rails::Generator::Base:Class (NoMethodError)
        from lib/ruby/gems/1.8/gems/rails-1.1.4/bin/../lib/rails_generator/options.rb:33:
        in `default_options'

OK, we’re almost there, but not quite there yet:

Keep in mind that we don’t officially “support” Rails just yet; there’s more work to do. We are, however, another leap beyond the JavaOne demo, and at this rate things are looking very good for an end-of-Summer JRuby 1.0.

I’m not sweating over it. Take your time and make it really rock, folks.

An Eclipse Rant

Why is it that everytime I try to upgrade from one stable Eclipse version (3.1 in this case) to a new one (3.2) I invariably end up having to do an install from scratch? Unzipping the new version over the old one resulted in lots of errors and non-functioning stuff, so I installed it all in a new directory, but then had to copy some plugins by hand and reinstall others using the Update Manager.

I also lost some of my preferences, like Java editing templates. Why aren’t those in my workspace directory, which is under my home directory and shouldn’t therefore get lost if I delete the old /Application/eclipse directory? The mind boggles.

Anyway, I’ve now got Eclipse 3.2 running on both my machines (the upgrade on the MacBook was relatively painless, being from a 3.2 milestone release instead of from 3.1). All is well that ends well.

Eclipse and Intel Macs

This is for a bunch of people I know that routinely use Eclipse on their Intel Macs:

EclipseZone – Eclipse and Intel Macs – apply …: “It’s quite likely that this is a driver issue with Mac OS X on Intel that was causing some of these problems, and Apple’s released QuickTime 7.1.1 that claims to fix some issues with startup items for Intel macs. In any case, bug 142892 has been tracking it, and it looks like applying this fix solves whatever the graphics card issue is, and Eclipse is running again. “

I didn’t have this particular problem (UI is freezed, even though mouse pointer moves, and you cannot even login from remote) when running Eclipse, but rather with other applications, like Opera for example. However, the symptoms were the same, so I dutifully upgraded Quicktime to 7.1.1, hoping they won’t surface again.

Technorati Tags: , , , .

Apache Abdera and ROME: alea jacta est!

Great news on the Atom front! The ARI project I mentioned a few days ago has changed its name to Abdera. This gives it a new fancy name while at the same time removing any ambiguity around its “reference” character. I’m really looking forward for it to come out of incubation.

As I had anticipated, I changed my code to use Abdera instead of ROME and it was a relatively quick and painless process. Just changing all Java package names and keeping references to “Entry” and “Feed” classes was enough to get most of the code to compile cleanly.

Last but not the least: James Snell suggested on the ROME developers’ list that Rome could use Abdera instead of its own Atom implementation, and he was met with loud cheers, as Pat reports. Personally, I’m all for dropping ROME’s feed model and replacing it with one based on Atom, as Atom can do everything that RSS does, and much better.

There’s also been talk of moving ROME to Apache, a move which I would personally applaud.

Technorati Tags: , , , , , , .

Atom Reference Implementation

atom-logo75px.gifJames Snell: “Just a couple of minutes ago I sent off a new proposal to the Apache Incubator PMC to consider incubation of ‘ARI’, a reference implementation of the Atom Syndication Format and Atom Publishing Protocol specifications.”

I’ve been working with Atom lately, specifically with the Publishing Protocol side of things, and have been using Rome, supplemented by some of Dave Johnson’s code. While Rome is a fine toolkit for all kinds of syndication needs, its support for the many variations of RSS tends to get in the way when all you need is Atom, and Dave’s code is too blog-centric for my needs, which have nothing to do with blogging.

So I welcome ARI and will have a look at the code ASAP but, judging from the latest spat of articles on James’ blog, it looks like it already provides a good set of features on the syndication front and some support on the publishing one. I’ll try to swap it in in place of my homegrown, Rome-based code and see if it works out.

Technorati Tags: , , , , , .

Ruby for Java Programmers, Part VI

In the previous episode from this series, I showed you how to use XML-RPC to call Java code from Ruby over the network. In this article, we will do the same, but using SOAP instead of XML-RPC. One advantage of SOAP over XML-RPC is the fact that SOAP endpoints can be described using WSDL and, by using Ruby’s extensibility, new methods can be created on the fly to mirror the methods declared in the WSDL, therefore giving us a lot of nice loose coupling.

Moreover, toolkits exist to automatically create WSDL descriptions from Java classes, so you won’t have to do it by hand. One of these toolkits, and the one we’ll be using in the examples here, is XFire. The most recent version of XFire available at the time I’m writing this is 1.1-RC1. I suspect this example will work just as well when 1.1 final is released. You’ll also need Java5 and Maven 2.

Maven is handy for automatically downloading all the necessary dependencies and running the demo inside a servlet container, using the Jetty6 plugin, without writing much code or configuration. Of course, you can always download all the necessary JARs by hand and drop them, together with the demo code, into the servlet container of your liking.

You can follow XFire’s Quick Start tutorial to set up a simple SOAP service, or you can simply grab a copy of this archive, which adds some more data to the tutorial sample, unzip it and run mvn jetty6:run from its root directory, once you have Maven installed. Go grab a cup of coffee while Maven downloads all the dependencies. Finally test that everything is OK by requesting a copy of the WSDL file from http://localhost:8080/services/BookService?wsdl.

On Ruby’s side, all that is needed is already provided by Ruby’s own core soap library, in particular SOAP::WSDLDriverFactory.

Here’s how you’d call your service from Ruby:

require 'soap/wsdlDriver'
WSDL_URL = 'http://localhost:8080/services/BookService?wsdl'
driver = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
books = driver.getBooks(nil)
p books.out.book[0].title
book = driver.findBook(:isbn => '222')
p book.out.title

A couple of minor nits:

  1. The BookService#getBooks method in Java takes no arguments, but if you try to call driver.getBooks without arguments, Ruby complains about a missing argument. Apparently, passing a ‘nil’ value fixes it, but I’d like to know why this is so.
  2. XFire add this extra ‘out’ element to its generated schema. This is mildly annoying as you always have to use it in order to access the real values you are interested in.

On the pro side, you can set up all of this with very little configuration. The only configuration that is going to change from one application to another is XFire’s services.xml file which maps service names to service classes, and even this is pretty straightforward:

<beans xmlns="http://xfire.codehaus.org/config/1.0">
  <service>
    <name>BookService</name>
    <namespace>http://sourcesense.com/BookService</namespace>
    <serviceClass>com.sourcesense.xfire.demo.BookService</serviceClass>
  </service>
</beans>

Technorati Tags: , , , , .