Creating a USB Flash Drive to boot VMWare VMvisor 5.0 installer

There are lot of guidelines available on how to create a bootable USB stick with VMware installer. Some of them use manual copying e.g http://www.ivobeerens.nl or http://www.techhead.co.uk or use the UNetbootin tool in Windows to create a bootable USB stick: https://community.emc.com.
But one major thing is to be obeyed: The USB stick must be formatted in FAT32 file system and the partition must be made active. Formatting the USB stick in Windows, all of this is done more or less automatically, but if you have only Linux at hand, you must follow a few steps that are also described in the vSphere 5 Documentation Center:

2 Create a partition table on the USB flash device.
/sbin/fdisk /dev/sdb
a Type d to delete partitions until they are all deleted.
b Type n to create primary partition 1 that extends over the entire disk.
c Type t to set the type to an appropriate setting for the FAT32 file system, such as c.
d Type a to set the active flag on partition 1.
e Type p to print the partition table.

The result should be similar to the following text:
Disk /dev/sdb: 2004 MB, 2004877312 bytes
255 heads, 63 sectors/track, 243 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 243 1951866 c W95 FAT32 (LBA)

f Type w to write the partition table and quit.

3 Format the USB flash drive with the Fat32 file system.
/sbin/mkfs.vfat -F 32 -n USB /dev/sdb1

SVN Statistics using StatSVN

While testing a few tools to quickly get useful statistics on SVN repository, I stumbled on StatSVN, which I liked the most. As it is written in Java, it should run on most systems. Just follow the instructions of the Quick Start section in the Wiki to create comprehensive statistics of your projects.

As StatSVN works on the svn log file you have to create for your checked out modules, it might make sense to create the logs only for a specific period of time:

svn log -v --xml -r {2011-06-30}:{2011-01-01} > log.xml

It is also possible to create joined statistics for several SVN modules. If you have a bunch of modules with branches you may want to make sure that you only check out the trunk portion of the modules and not all branches. For this, check out all the modules you have in the SVN repository but only the first level:

svn checkout --set-depth immediates;

This should give you the wanted directory structure. Now ”cd” into each module directory and check out the ”trunk” part of each module:

cd MODULE_DIR
svn update --set-depth immediates;
cd trunk;
svn update --set-depth infinity;

After creating the appropriate svn log file you can generate the statistics by invoking StatSVN, e.g.

java -jar /path/to/statsvn.jar /path/to/module/logfile.log /path/to/module

Re-scanning SCSI bus for new devices

It might be useful to re-scan the SCSI bus when a new device has been plugged in, e.g. via VMWare ESXi configuration changes, that has not been automatically identified by the OS. In Debian/Ubuntu you can do the following:
sudo apt-get install scsitools
sudo rescan-scsi-bus.sh

You can check the /sys/bus/scsi/devices/ directory before and after the re-scan and via dmesg to which device node in /dev directory e.g. the new harddisk has been added.

Don’t forget about the environment when you use cron

The commands that are executed via cron are started in a different environment than the one you have while you test the command in a shell. The blog entry of Mike Tremell explains the reasons and gives solutions to the problem. The easiest one is to set up the correct environment in a script that you call in a crontab:

. /etc/profile
. /home/user/.profile

%-sign in crontabs

The %-sign has a special meaning in crontab.

man 5 crontab:

“…Percent-signs (%) in the  command,  unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent

to the command as standard input. ”

So don’t forget to escape the %-signs with a backslash if you use them for example to format the date output:

`date +'\%Y\%m\%d'`

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>