Archive for the 'java' Category

Integrate Cocoon with Lucene for Full Text Search of Unstructured Data

DodoJust found out today that there is a couple of Cocoon-related articles on DevX.com:

Integrate Cocoon with PostgreSQL for XML-driven Apps: “XML and relational databases are a natural fit. Learn how to access PostgreSQL data from Cocoon, so you can develop robust XML-driven applications with a relational backend.”

Integrate Cocoon with Lucene for Full Text Search of Unstructured Data: “By wrapping the Lucene search engine's return data in XML and then using Cocoon's XML-handling capabilities, you tap into the power of XML for multi-channel publishing of unstructured information.”

Unfortunately these articles are a bit outdated, as they present XSP and actions as the prototypical method of integrating data access in Cocoon, while the truth is that they are quickly going the way of the Dodo, to be supplanted by flowscript and the JXTemplate system. You've been warned!

java.awt.headless=true

If you've been trying to post a comment on this weblogs in the last hours, you couldn't because, after having enabled the SCode plugin for blojsom, I forgot to add one very important extra option to the Tomcat configuration:

-Djava.awt.headless=true

Without this option, Java will try to connect to the X server to do whatever it needs to do in order to generate an image. And since I stopped X before going home yesterday, the result is that the CAPTCHA image was not being generated.

I should have known better. I't about the twelfth time that I trip upon this gotcha.

Father of Java chides open source developer community

James Gosling
Would someone please hit Mr. Gosling on the head with a cluestick?

These businesses are more hype than reality. If they don’t have a [longer term] economic model…they are going to have a really hard time.

(Source: Computerworld)

You’re bound to expect such trite remarks from the likes of Gates and Ballmer, not from a bearded, t-shirt wearing (and hurling) geek.

Maybe we should his ask ponytailed COO what’s the economic model behind the opensourcing of Solaris 10.

Or why another of the executives at his company has “Open Source Diva” written as a qualification on her business card.

To be honest, there’s always the possibility that Computerworld simply took some quotes out of context and stuffed words in his mouth. You know, journalists are not above those tactics, at times.

(via Bruce)

Update: I am pretty sure that Sun does have an economic model for Solaris 10 and I hope the very best for them, seriously.

What I am at odds with is statements like These businesses [MySQL, JBoss, and Red Hat] are more hype than reality.

And I have to admit I was put off by the title of the article. I had to look up to chide in a dictionary (To scold mildly so as to correct or improve; reprimand: chided the boy for his sloppiness.) since English is not my mother tongue just to be sure. But, of course, the title is not James’ fault.

XML-RPC and UTF-8

Today I was trying to retrieve content from a Confluence instance via XML-RPC and fell hard upon encoding issues. Turns out Apache's XML-RPC library doesn't support UTF-8, which is what Confluence uses.

After a bit of googling around, I found Tom Bradford's alternative XML-RPC client library et voila, problem solved!

Thanks, Tom.

Nutch incubated

If you need to search your intranet, you'd better have a look at Nutch. Now with the Apache feather.

logo_nutch.gif

Hibernate Review

Hibernate logo

Even though some vehemently disagree, it is my firmly held opinion that Object/Relational Mapping (ORM for short) is a powerful weapon in the arsenal of any entrerprise developer working with an Object-Oiented language. Should you decide to take the plunge and use a full-featured ORM tool for your next project, after you have done some research, it will be evident that there is a great deal to choose from, even if you limit yourself to Open Source, Java libraries. Everybody seems to have rather strong opinions on the matter. The only point on which you will find agreement from most parties is that EJB sucks, but that’s another story.

I won’t try to convince you that Hibernate is the best solution, mostly because I have almost no hands-on experience with JDO, OBJ or other similar tools. What I have to share is a two year long, mostly positive, experience with Hibernate, having developed a dozen or more projects with it.

What’s so good about Hibernate?

  • Non-intrusive, almost completely transparent, persistence for Plain Old Java Objects (POJOs). In short, you don’t have to extend Hibernate-specific interfaces in order to make an object persitent and you don’t have to obey unnatural rules (like “no inheritance”). You can use plain object references and Java2 collections to express relationships and you can map rather complex cases, including class hiearchies, with Hibernate.
  • No need for pre- or post-processing of source- or byte-code. This means a simpler tool chain and quicker edit-compile-deploy cycle.
  • Good tooling, although it might be better.
  • Good docs. Plus, there are lots of books dealing with Hibernate. I reviewed one of the best here.
  • Very robust, bug-free and performant code.
  • Caching.
  • A very good query language (HQL), with the option of falling back to SQL when you need it.
  • Much more…

What’s not so good about Hibernate?

Well, the only real gripe I have with it is probably the fact that, for all practical purposes, Hibernate is owned by JBoss. Not that I have anything against Mr. Fleury’s gang, but given JBoss’s revenue model (support and services), it might come as no surprise that suppport is relegated to a forum (I would prefer a mailing list, but that’s just me) and responses from the development team tend to be just a little bit terse, at times.

On the other hand, this is perfectly legit. If you want pro-level support, even with an Open Source project, you should be prepared to pay for it.

All in all, I give Hibernate 5 stars (out of 5). Highly recommended!

Re: Applying for a Java job - HOWTO

I'm sure I would have no problem matching most of
the criteria Mike lays down as prerequisites for getting a job at Atlassian. I have a decent grasp of English language, relevant experience, have contributed to a few open source projects and keep a blog. I am a JIRA user too.

Only problem, I am not available for an interview in Sidney :(. For locations nearer to home (Italy), my resume is available here. It's PDF, but not written in pink ;).

Hibernate in Action Review

bauer_cover150.jpgHibernate in Action by Christian Bauer and Gavin King, Manning Publications.

Hibernate is arguably one of the most interesting and useful Open Source projects around. If you develop enterprise Java applications that have to do with a relational database (and which one doesn’t?), then you should seriously consider using an Object/Relational Mapping (ORM for short) tool as an alternative to straight JDBC, in particular if you have a rich domain model and you’d like to exploit the object-oriented features of the language, like polymorphism, and core libraries like the Collections API.

This book comes straight from the source. Gavin is actually the founder of the project and Christian is one of the most prominent developers. It is not surprising, therefore, that the book explains some of the design decisions that have shaped Hibernate into what it is now, like using runtime bytecode generation in preference to source code generation or post-compilation bytecode manipulation.

Hibernate is not easy to learn and use proficiently if you’re not prepared to study it thouroughly and this book does a good job of explaining tricky subjects like the persistent objects’ lifecycle, exotic mappings, transactions and so on. However, it would be quite hard to use it as a single reference source while working with Hibernate. You should be prepared to refer constantly to the reference documentation, the API docs and the huge knowledge base available through the online forums.

At a little more than 400 pages, it is not a particularly thin book, yet I would have appreciated a more systematic treatment of the APIs and the different types of mappings, with more code samples. As it is, you’ll find it a very useful and interesting book if you’re about to start a new project and want to know whether Hibernate is the right solution to your persistence problems. If you’re a developer interested in using Hibernate, I suggest giving it as a present to your technical mamanger or team leader. In this case, I’d give it five stars

On the other hand, if you’re already experienced with Hibernate, it is much less useful but nonetheless very iteresting and well-written, so I’d give it four stars.

Average evaluation: 4.5 out of 5.

Hibernate in Action

bauer_cover150.jpg
I’m currently reading Hibernate in Action by Christian Bauer and Gavin King. Having read the first five chapter so far, I’m pretty much impressed by the thourough treatment that is given to the rationale behind using an ORM tool and Hibernate in particular. The chapter on transactions is very illuminating.

I hope to post a comprehensive review once I have finished reading it.