Passing Hudson BUILD_NUMBER to Sonar Plugin

Sonar is a great source code analysis tool that integrates through its plugin neatly into the Hudson continuous integration server. One major feature of Sonar is the module called “Time machine” where you can review the progress of the quality metrics for your project over time. However, to see this progress, it is necessary to tag the version of the Sonar run dynamically, otherwise, the new run “overwrites” the previous results. Sonar does not really discard the old results, but to fetch the older outcomes in the Time machine view is quite tedious.

So, what you need to do is really simple:

  1. Pass the BUILD_NUMBER to the Maven call in the field “Additional properties”
  2. Have the Sonar Plugin insert a variable for replacement in the generated POM file

In my example the replacement variable is called “version” but you can name it as you want.

Pass a variable Version Number to Hudson Sonar Plugin
Pass a variable Version Number to Hudson Sonar Plugin

With the shown configuration Sonar will store the results under “hudson-##” where ## is the current iteration of the Hudson build cycle. Of course it is also possible to pass other information, like the BUILD_ID or JOB_NAME. A listing of available Hudson environment variables can be found here.

Andreas

Save a Sharepoint Password in Firefox

Using a Sharepoint site is for Firefox users can very annoying as the Website, for what reason whatsoever, does not allow the Web browser to store the password. Some other sites also disallow for security reasons to store the password in the browser.

Sometimes, the trouble even doubles as the user can not change his/her Sharepoint password and always has to lookup the cryptic generated password.

However, there is a solution for allowing Firefox storing the password available:

  1. Go to the Login page of the Sharepoint Website
  2. Enter you username and password
  3. Copy the JavaScript code below into the Firefox Location bar
  4. Hit Enter and click on sign in
  5. Voilà, Firefox asks you if you like to save the password.

Copy this one into the location bar as it is written without any newlines:

javascript:(function(){var ca,cea,cs,df,dfe,i,j,x,y;function n(i,what){return i+" "+what+((i==1)?"":"s")}ca=cea=cs=0;df=document.forms;for(i=0;i<df.length;++i){x=df[i];dfe=x.elements;if(x.onsubmit){x.onsubmit="";++cs;}if(x.attributes["autocomplete"]){x.attributes["autocomplete"].value="on";++ca;}for(j=0;j<dfe.length;++j){y=dfe[j];if(y.attributes["autocomplete"]){y.attributes["autocomplete"].value="on";++cea;}}}alert("Removed autocomplete=off from "+n(ca,"form")+" and from "+n(cea,"form element")+", and removed onsubmit from "+n(cs,"form")+". After you type your password and submit the form, the browser will offer to remember your password.")})();

A more readable form of the JavaScript:

javascript:(
  function()
  {
    var ca,cea,cs,df,dfe,i,j,x,y;
    function n(i,what)
    {
      return i+" "+what+((i==1)"":"s")
    }
 
    ca=cea=cs=0;
    df=document.forms;
    for(i=0;i<df.length;++i)
    {
      x=df[i];
      dfe=x.elements;
      if(x.onsubmit)
      {
        x.onsubmit="";++cs;
      }
      if(x.attributes["autocomplete"])
      {
        x.attributes["autocomplete"].value="on";
        ++ca;
      }
 
      for(j=0;j<dfe.length;++j)
      {
        y=dfe[j];
        if(y.attributes["autocomplete"])
        {
           y.attributes["autocomplete"].value="on";++cea;
        }
      }
    }
    alert("Removed autocomplete=off from "+n(ca,"form")+" and from "+n(cea,"form element")+", and removed onsubmit from "+n(cs,"form")+". 
    After you type your password and submit the form, the browser will offer to remember your password.")
  })();

The script simply removes the HTML attribute “autocomplete=off” and has to be executed only once. You can check now if your password has been stored in the Firefox settings.

One minor issue remains: As the next time you visit the login page, the autocomplete attributes are active again, you must enter your complete login name, but this is quite easy to remember and the password will be automatically inserted by Firefox.

Reference: Force Firefox to Offer to Save …

HTH,

Andreas

JBoss 4.0.5: javax.naming.NamingException: Could not dereference object

If you experience such an error it is very well based on having the JBoss server and/or the clients started using JDK 6.0. Some more explanations can be found in JBoss Forum topics here and here.

Sometimes I run in this problem as my production systems still use JBoss 4.0.5 GA. Beginning with JBoss 4.2.0GA this error should not appear anymore. Sometime in future I will update my servers. Until then, I will stick with JDK 1.5.0.

Snow Leopard: MyEclipse, Subeclipse and Java 6

Having moved from Mac OS X 10.5 (Leopard) to Mac OS X 10.6 (Snow Leopard), the Subversion integration into MyEclipse IDE 7.5 using Subeclipse did not work any more. More precisely, when opening the repository item in the SVN Repositories view, I got the dialog

Screen shot1

and an error message in the console saying

Screen shot 2

After trying to remove and reinstall the Subeclipse plugin without any improvement, I found a solution solving my problem after installing and using the JDK Version 1.5. For a detailed description look here: Snow Leopard and MyEclipse Fix Resolution and here http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard.

After installing the JDK 1.5, just move the J2SE 5.0 32-bit in front of the Java SE 6 32-bit within the Java Preferences utility. The 64-bit JDKs are not taken into account (yet) and can be left even on top of the 32-bit JDKs.

If you use the encryption API of Java, make sure you download and install the Unlimited Strength Jurisdiction Policy Files in the appropriate directory:

/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard/Home/lib/security

Otherwise you might get errors like

java.security.InvalidKeyException: Illegal key size or default parameters

Good luck.

Optional ant tasks in separate build.xml file invoked with Maven AntRun plugin

In a legacy development project, ant build.xml files are used for compilation and packaging. To integrate new features more easily, I decided to use Maven and the AntRun plugin. The original targets can simply be invoked as it is explained in the examples.

However, if you want to use taks not included in the default jar, e.g. the optional ant tasks, you have to correctly add the dependencies to the AntRun plugin. Unfortunately, I moved the dependencies to the global section of my pom.xml. This mistake took me a quite some time to fix, as I simply oversaw it. 🙁

Just make sure, it looks like this:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <dependencies>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-nodeps</artifactId>
      <version>1.7.0</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
    ...
    </execution>
  </executions>
</plugin>

Lotus Notes 8.5 can not delete attachments anymore

I recently upgraded my Lotus Notes client on my Mac to version 8.5. In the previous releases, it was possible to select an attachment, right click and say “Save and Delete …”. Now, this option is grayed out when the mail has it’s origin outside of the organisation. The workaround I found is the following:

  1. Put the message into edit mode
  2. Save the attachment as usual
  3. Hit the delete button on the keyboard while the attachment is still highlighted.

There you go…

Writing udev rules to create symbolic link for Huawei E220 USB GSM/UMTS Modem

On an Ubuntu 8.04 server, I connected a Huawei USB modem to send SMS using SMSLib. Normally, the modem interface can be found under /dev/ttyUSB0. For some reason, the system decided to mount the modem interface using /dev/ttyUSB1. To avoid to always reconfigure SMSLib, if such a change occurs, I decided to use udev rules to create a specific symlink for the modem interface.

1. Check with lsusb if the device is connected:

prompt> lsusb
Bus 005 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem
....

2. Somewhere in /var/log/messages you should find an information, to which devices the different ports of the modem have been mapped to. In my case, it is:

Jul  9 08:50:07 server kernel: [4378805.151459] usb 5-5.1: airprime converter now attached to ttyUSB1
Jul  9 08:50:07 server kernel: [4378805.151488] usb 5-5.1: airprime converter now attached to ttyUSB2
Jul  9 08:50:07 server kernel: [4378805.151513] usb 5-5.1: airprime converter now attached to ttyUSB3

3. After checking with minicom that ttyUSB1 is the correct port, I used

udevinfo -a -p $(udevinfo -q path -n /dev/ttyUSB1) > ttyUSB1.info
udevinfo -a -p $(udevinfo -q path -n /dev/ttyUSB3) > ttyUSB3.info

to retrieve information about the different device information stored in the udev database.  Simply running diff on the information shows you some hints, how to differentiate the devices and only create a symbolic link for one of those ports. In my case, the diff showed following results:

8,9c8,9
<   looking at device '/devices/pci0000:00/0000:00:1d.7/usb5/5-5/5-5.1/5-5.1:1.0/ttyUSB1/tty/ttyUSB1':
<     KERNEL=="ttyUSB1"
---
>   looking at device '/devices/pci0000:00/0000:00:1d.7/usb5/5-5/5-5.1/5-5.1:1.0/ttyUSB3/tty/ttyUSB3':
>     KERNEL=="ttyUSB3"
12c12
<     ATTR{dev}=="188:1"
---
>     ATTR{dev}=="188:3"

4. Using the information ATTR{dev}==”188:1″ and ATTRS{product}==”HUAWEI Mobile” in a parent device, I came up with the following udev rule that I put into /etc/udev/rules.d/98-modem.rules:

KERNEL=="ttyUSB*", ATTR{dev}=="188:1", ATTRS{product}=="HUAWEI Mobile", SYMLINK+="ttyS20"

According to the great tutorial Writing udev rules by Daniel Drake, it is not possible to mix attributes from different parent devices. This is why I used the ATTR{dev}==”188:1″ and not ATTRS{port_number}==”0″ as I already used ATTRS{product}==”HUAWEI Mobile” in a different parent device. (You could also ATTRS{idVendor}==”12d1″ and ATTRS{idProduct}==”1003″ to specify the modem instead of the product attribute.)

5. Simply let udev know about your newly created rule and check, if the system created the correct link:

promtp> sudo udevtrigger
prompt> ll /dev/ttyS20
lrwxrwxrwx 1 root root 7 2009-07-10 08:12 /dev/ttyS20 -> ttyUSB1

Now you can use the device /dev/ttyS20 in your SMSLib configuration. To be used in SMSLib, the symbolic link should be named to something resembling a standard serial port, like /dev/ttyS*. If you do not so, it is possible that SMSLib (or the used RXTX lib) does not correctly recognise the serial port. It my first try, I named the symbolic link /dev/huawei_modem. Minicom was fine with that, but SMSLib did not like it.