Now upgraded from 3.3.2 to 3.3.3, it has been out for nearly half a year, but I have just not noticed it. Just a few bug fixes, easy and simple upgrade – b2evolution rocks!!
rblog
Creating my first Build Forge adaptor
This week I’m attending a two day course as an intro to Build Forge, followed up by a two day workshop on the use of RAFW. Between the lessons I have tried to create a simple adaptor to Build Forge which does nothing more than call a batch file and return the current date to the Bill of Materials. Not rocket science, but I need to start simple to learn it 🙂
I got the bat file from http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/ I just edited it a bit, making this the last line
echo Current date: %dd%.%mm%.%yyyy%
Calling a bat file like this might seem kinda stupid, but since adaptors are meant to enable you to call executables using command line, stupid is ok for now. The XML for the adaptor calling the bat file is like this
<?xml version="1.0"?>
<!DOCTYPE PROJECT_INTERFACE SYSTEM "interface.dtd">
<PROJECT_INTERFACE IFTYPE="Source" INSTANCE="7.02">
<template>
<env name="FILEPATH" value="path_to_file_with_ending_slash" />
<env name="FILENAME" value="name_of_bat_file_to_run" />
</template>
<interface name="ByDate">
<run command="command" params="$FILEPATH $FILENAME" server="$BF_SERVER" dir="/" timeout="360"/>
</interface>
<command name="command">
<execute>
$FILEPATH$FILENAME
</execute>
<resultsblock>
<match pattern="^Current date: (.*)">
<bom category="Result" section="CurrentDate">
<field name="currdate" text="$1"/>
</bom>
</match>
</resultsblock>
</command>
<bomformat category="Result" title="Current Date">
<section name="CurrentDate">
<field order="1" name="currdate" title="Date"/>
</section>
</bomformat>
</PROJECT_INTERFACE>
(Using Blogcrowds to escape the XML)
Note that you also need to create an environment in Build Forge containing the two variables in the template-section. The adaptor xml only describes them, it does not instantiates them. So create the environment and refer to it in your project or the step.
I would also recommend playing around with the bomformat-tag, which enables you to format the “Bill Of Material format”, creating headers, sections and fields.
Bash – Insert content of one file into another file
Had to insert a XML-snippet into another XML-file at a given location in a Bash-script. Reading the snippet into a variable is quite easy, just by using cat. The trouble was how to find the tag to replace most efficiently, then replace it with the xml-snippet. Learned that reading the file content using stdin/stdout in a bash-script can cause side effects not easy to figure out, so that was no option. Instead I first tried to use sed, but sed had problems with the fact that the content of the snippet is XML-code. So instead with good help from Geir we ended up using Perl, which made it all very simple – everything done in just 2 lines of code.
First it searches for <!– END jaas –> then replaces the string with the content of the snippet variable and lt;!– END jaas –>
value=$(cat jaas_snippet.xml)
perl -pi -e "s#<!--\sEND\sjaas\s-->#${value}\n\t\t<!-- END jaas -->#" jaas.xml
Comments:
- Using # instead of ` – while struggling with XML in the variable $value
- \s = whitespace, like \n is newline and \t is tab
- Double quote’s so that perl uses the value of the variable, and not just reads it as plain text
- In this case we expect only one occurrence of the end-tag, so we have skipped the /g parameter at the end of the search-string. /g meaning global, compared to for instance the usage described in my previous blog post at WPC.
Perl is power!
Usability on the wild side
How to exclude files when using ls
Had a directory with > 150 *.properties-files and needed to check if there where any files not ending with .properties. ls lists all the files, combine it with grep and you are saved.
# See all files ending in .html
ls | grep “\.html$”
# see all files not ending in .html
ls | grep -v “\.html$”
Solution found at unix.com
A picture is not proving anything
Spend five minutes watching this video showing the new feature in the next version of Photoshop “Content-aware fill”. You can delete everything, and that really means everything!
[video:youtube:NH0aEp1oDOI]Pretty hardcore…
How to analyze a heap dump
In fact, analyzing the heap dump is not rocket science, many tools are available to do this. My intention was to use the IBM Support Assistant and then install the MDD4J-plugin on my laptop. All done without much hassle, so then of to analyze the actual heap dumps made available to me. Problem was that the dump-files are all about 400Mb, which it turns out my Windows XP-running laptop ain’t capable of managing. Tried to change default heap size for the tooling by following the steps I found in this post on Developerworks, but no help. I still got the “negative size” error. This was when using the 2.0.x version of MDD4J.
So, I tried to use the beta version of the 3.0.1.x version of MDD4J. I got rid of the negative size-error, just to get a new one “Capacity is less than zero”. Did a Google-search and found yet another post on Developerworks, with one reply from a guy named Thomas who is part of the MDD4J development team saying:
Hello everyone, this is Tomas, I’m a member of MDD4J development team.
I’m posting this just to confirm that in cases when MDD4J is unable to run analysis on a 32 bit platform, the right solution is to follow the instructions on how to run the analysis outside of ISA. The best combination is a 64bit Linux machine with IBM’ 1.5 JRE.
After running the analysis, you can copy the analysis directory back to your ISA’s workspace, into directory: <user home>/ibm/isa41/.metadata/.plugins/com.ibm.websphere.mdd4j.betaTomas
…so, just forget my Win XP and instead off to find a running Linux installation which I can use.
Things I do on a Saturday evening: Installing WAS CE on Ubuntu
Spent about an hour or so in total this evening installing WebSphere Community Edition on my own laptop where I run Ubuntu 9.10. Needed an application server to deploy the web applications I create when trying to teach myself how to do Java development. The first try was to install Tomcat 6, which was quite easy using the package manager. But after I had done some thinking I turned to WAS CE instead, why not, since WebSphere is the product I know best (beeing well aware of the fact that under the hood in WAS CE, you will, among various open source projects, find Tomcat as well).
The installation was quite easy, just followed the Quick Start-guide combined with the Setup Troubleshooting (Prerequisites for Ubuntu, read this one first!!). After that I just had some issues with getting WAS CE to understand where to find the correct Java installation, but this guide saved me combined with me just realizing that I have to run it as root. Guess I could avoid that, but who cares, it is my own laptop.
Anyhow, this is the admin console, so the next step will be to deploy applications from Eclipse, but that will be another day…
@Update: Not a problem at all to get rid of the root:root
> su
> cd /opt
> chown -R myuser:mygroup IBM/
> exit
> cd IBM/WebSphere/CeAppServer/bin
> ./start-server.sh
…server started…
Found new hardware wizard keeps appearing
Had a problem at work, my laptop running Windows XP kept notifying me every second “Found new hardware Nokia 6280”. A bit tricky to get rid of it, found the solution way down on this post
GO INTO DEVICE MANAGER
GO TO VIEW
SELECT SHOW HIDDEN DEVICES
CLICK THE PLUS SIGN NEXT TO PRINTERS….
IS THEIR AN EXCLAMATION POINT ? if so select properties check and see what it says
TRY SELECTING DISABLE from the properties of it OR SELECT UNINSTALL SEE IF THE PRINTER STILL WORKS
Killed the problem!!
The Maven Ant plugin and JAVA_HOME
I’ve spent some time, with great help from two of my colleagues, creating a pom.xml using the Maven Ant plugin to call Ant targets in the build.xml file downloaded along with the source code for JMeter. Got the plugin working without to much struggle, but when trying to call “ant compile” from Maven “mvn compile” I got an error saying that no compiler was found since the JAVA_HOME variable was pointing to “…\jdk\jre” But all attempts to change the variable to “..\jdk” just returned the same error. Very strange since I could compile other Maven-projects without any problems and calling compile using Ant directly caused no problem.
But, then as always, Google to the rescue. The line below in bold was all what I needed.
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<property name="build.compiler" value="extJavac"/>
<tasks>
<ant antfile="${basedir}/build.xml">
<target name="compile" />
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
Found a post where someone else had got an error trying to use the maven-antrun plugin. It is in fact a property passed on to Ant, see ant.apache.org/manual/CoreTasks/javac.html

