Yet Another Crap Mission

Just to let you know about my state of despair right now, I’m now involved (single-handedly, with a project leader and someone above and me to handle the whole s***) in a project with VisualAge for Java 4.0, to make Swing screens (remember how “great” the visual composition is with VAJ) and JDK 1.2.2. No CVS or anything, which is just a fine idea amongst others and allowed me to lose everything I’d done yesterday at VAJ first crash.

So I came in this morning with the firm intention to tell VAJ what I really thought of it. Redid everything, taking care to release versions. Well, looks fine. But that was a bit presomptuous on my part. Anyway, around 10 this morning, VAJ started to behave erraticly, complaining about whatever bean or user java code which happens to be not responding. Then crash. I’ve been trying to restart it, fix it, uninstall it, reinstall it ever since. Still no luck.

I’m kind of pissed off to be forced to use VisualAge. I thought it was behind me when I last used it in a project 3 years ago. And I was not even using Swing on that project but the quite good WebSphere Test Environment… I think it’s a mixture of having 2 or 3 JDKs on my machine which runs Win 2000.

Well, to be frank, I’m kind of pissed off. Full stop.¶

Smoking Ban

The “Smoking Ban” debate has been going on and on and on, and now that it is in place, ink (and bytes) is still flowing about it: Daily Moiders is the latest contribution to this discussion. Marc Mulholland sounds quite unhappy with the ban and in fairness to him, when all this started, I had the same view about the topic. But not anymore.

Maybe passive smokers are not that affected by smoke in public places. But smokers themselves, wherever they are, are in danger. I think – as a smoker – that it is a good law: it makes the smoker be aware that smoking is unhealthy (not to say worse). The smoker is going to feel guilty to smoke, even more that he or she probably already feels for in the past decades, smoking has become a fairly anti-social habit. The fact that the law now unwelcomes cigarettes in public places in Ireland is going to ostracize even more the smokers.

At first, it sounds dreadful – sounds like secluding a group of people. But at the end of the day, all this should have positive result on us (smokers) and make us quit. If all warnings about cancers, both on television and on the packs don’t manage to help us, maybe using this means (guilt) is a more efficient one.¶

Craic agus Ceol

If you’re asking, excellent week-end, thank you. I was in Wales to attend a wedding some miles away from Swansea, in a lovely little village called Llandybie. Lovely ceremony, both in Welsh and English. Lots of singing – I learnt that “calon” in Welsh has just the same meaning as in Breton, heart, which would make of me someone called braveheart in Welsh too, funly enough – lots of drinking, lots of dancing… Good craic, that’s for sure.

Being the only the only Frenchman amongst Irish, Welsh, Scots and English, it is been somewhat exciting to follow – in a remote manner – first a wonderful Irish Triple Crown and then a French Grand Slam celebrated by everyone but the English.

PHP 5: “Ready to Serve!”

PHP 5

PHP 5 is in the pipes: Zend has recently launched its PHP 5 Infocenter.

On the menu, resources about PHP 5 novelties, like:

  • Improvement of the object-oriented support;
  • Facilities to handle XML in an easy way;
  • SQLite support;
  • Tidy and Perl extensions.

In this center, there is also an overview of the new Zend Engine II, redesigned to suit the OO needs, as well as i18n and exceptions.

SQLite

SQLite support has been included apparently because of MySQL change of licence (from LGPL to GPL); as far as I understood, it means that PHP will prefer SQLite to MySQL and the MySQL support will have to be activated to be used. To be honnest, I had never heard of SQLite before and it is said to be “compact and fast”:

Two times faster than PostgreSQL and MySQL for many common operations.

First impression: YADb! I guess we’ll see if it begins to be used or not, if the performance claims are proved to be true, if, if… For the moment, I guess people will stick to MySQL: too many changes would have to be done – and yes, because of lame coding.

Back on Java Track: JBoss3.0TemplateAndExamples

Times are pretty quiet at the moment, and I thought it was just about time to go back to J2EE. Since I was willing to give a look to JBoss that I’ve not used for quite a while, I stumbled upon this article written by Phil DeJarnett on Netbeans.org website. I just followed the recipe and discovered that there is a mock application which can be used to start with JBoss, called JBoss3.0TemplateAndExamples.

I downloaded the whole lot, along with JBoss 3.2.3 and XDoclet 1.2. I was first frustrated to see that it was not quite a “plug-and-play” operation: the Ant file delivered with the templates wouldn’t compile:

XDoclet classpath missing J2EE classes
        at xdoclet.modules.ejb.EjbDocletTask¶
                   .validateOptions(EjbDocletTask.java:85)
        at xjavadoc.ant.XJavadocTask.execute(XJavadocTask.java:94)
        at org.apache.tools.ant.UnknownElement¶
                   .execute(UnknownElement.java:166) etc.

What I didn’t know starting from there is that it would take me quite a while before I could really make it run… Here are the steps I’ve followed to do so.

Ant file

I had therefore to update the Ant file and add the following in the xdoclet-generate target:

<taskdef
   name="ejbdoclet"
   classname="xdoclet.modules.ejb.EjbDocletTask"
>
   <classpath>
       <fileset dir="${xdoclet.home}/lib">
           <include name="**/*.jar"/>
       </fileset>
       <b>&lt;fileset dir="${jboss.client}"&gt;
           &lt;include name="**/*.jar"/&gt;
       &lt;/fileset&gt;</b>
   &lt;/classpath&gt;
&lt;/taskdef&gt;

Names and JNDI

After having made those few changes, I managed to compile the test application. But that was certainly not the last step of my long journey towards deployment. The application wouldn’t deploy because of the following error:

The ejb-name for a CMP2.x Entity must be a valid Java Identifier

I then changed the name for my CMP EJB, TestEntity from test/TestEntity to TestEntity, both in TestEntityBean and TestSessionBean which refers to the latter. The reference to the CMP EJB looks like this:

* @ejb:ejb-ref ejb-name="TestEntity"
*              ref-name="ejb/TestEntity"

Finders

But the EJB still wouldn’t deploy, JBoss complaining about the fact that the EJB were not spec-compliant.

Several reasons for that. First of all, it looked like the @jboss directives, supposed to generate the finders were not working properly. I moved the @jboss directives into plain EJB-QL queries for the TestEntity bean:

* ejb:finder signature="java.util.Collection findAll()"
*            query="SELECT OBJECT(t) FROM TestEntity t"
*
* ejb:finder signature="test.interfaces.TestEntity findByName( &para;
java.lang.String pSurname, java.lang.String pLastName )"
*            query="SELECT OBJECT(t) FROM TestEntity t&para;
WHERE t.firstName = ?1 AND t.lastName = ?2"
*
* @ejb:finder signature="test.interfaces.TestEntity findAnotherByName( &para;
int pId, java.lang.String pSurname, java.lang.String pLastName )"
*            query="SELECT OBJECT(t) FROM TestEntity t WHERE t.id &lt;&gt; ?1&para;
AND t.firstName = ?2 AND t.lastName = ’?3’"
*

I also removed in the BMP Bean the @ejb:finder directive and wrote the finder in the bean:

 public java.util.Collection ejbFindAll(  )
   throws FinderException
{
   DataSource lDataSource = getDataSource();
   Connection lConnection = null;
   PreparedStatement lStatement = null;
   java.util.Collection result = new java.util.LinkedList();
   try {
      lConnection = lDataSource.getConnection();
      lStatement = lConnection.prepareStatement(
         “SELET Id FROM TestEntity”
      );
      ResultSet lResult = lStatement.executeQuery();
      while( lResult.next() ) {
          result.add(new TestBMPEntityPK(lResult.getInt(1)));
      }

      return result;
   }
   catch ( SQLException se ) {
      throw new FinderException( “Could not find record from DB: “
       + se.getMessage() );
   }
   finally {
      if( lStatement != null ) {
         try {
            lStatement.close();
         }
         catch( Exception e ) {}
      }
      if( lConnection != null ) {
         try {
            lConnection.close();
         }
         catch( Exception e ) {}
      }
   }
}

Local and LocalHome

The last error to occur was that the entity bean was produced without its Local and LocalHome classes. The solution for that was to add the associated XDoclet tasks, &lt;homeinterface&gt; and &lt;localhomeinterface&gt;.

And it worked <sigh>:

New Entity Id is: 2

Take your Pick

If you happen to want to do the same, the zip containing the template for JBoss can be found here. As I may have forgotten to mention changes I’ve made, here are the ones I’ve modified:

I’m aware of the fact that I’ve decided to take easy shortcuts to reach my goal but you’ll have to keep in mind that my original plan was to have a plain look at JBoss… I hope this will help and if you manage to do it in a much cleaner way, I’d be quite happy to hear about it.

Low Carb and Beer

Last Wednesday was Paddy’s Day and apparently it was mayhem in Grafton Street and Stephen’s Green (according to the listeners of RTÉ /liveline/) as well as in Belfast. Probably because of alcohol.

Alcohol is bad for your health. And beer makes you fat. That’s why BellaOnline provided us with this article, mentioning beers such as Corona Light, Bud Light, Amstel Light… Never heard of those before but I must the idea is quite scary…

That’s Sweden for You

Since I’m on holidays, Weblogism tends to become very Symphony of the Good Auld Worldish, but that’s great fun, isn’t it? Well, anyway, Ellen and I have planned to go to the cinema tonight to see Big Fish. “Well, pretty easy,” she said, “We’ll book the tickets on the Internet.” Fair enough, she went onto sandrewmetronome.se and started to book.

At some point, a little pop-up opened and a Java applet started to run. And here’s what we got:

bio.png

You can just choose your seat within the cinema just by clicking on the right place. Very ergonomic, very quick, very handy. That’s Sweden for you!

Ellen explained to me that she had done that once and the application asked her (with all the Swedish courtesy) if she wanted to send an automatic SMS to her friend telling her about the film, the time and the place. And I thought of all the hassle you get when you want to go and see a film in Chatelet-Les Halles in Paris, crying on all this precious time lost in queueing stupidly.¶