Wednesday, August 8, 2007

The JNI UnsatisfiedLinkerError saga

Ever try to debug something where the solutions you found on the net does not seem to work in you machine ? Well I had one today.

Its actually related to the rather infamous UnsatisfiedLinkerError when running JNI related applications. My test code compiles OK & the DLL was built successfully. Nonetheless at runtime, said error always pops up.

I tried in vain at numerous compilation options as suggested on forums I found on the net but to no avail ... until I noticed this:




The UnsatisfiedLinkerError actually came from the line:


JNIEXPORT void JNICALL Java_ArrayHandler_returnArray


But since the ArrayHandler is actually in a package called org.semi, an UnsatisfiedLinkerError will arise at runtime. The correct signature would be as follows:


JNIEXPORT void JNICALL Java_org_semi_ArrayHandler_returnArray



Had a great laugh after I discovered this. There goes one day debugging something which should be obvious all along :)

The sample code I did can be downloaded at rapidshare, well, if they haven't deleted it yet :)

Microsoft Word tips

I found these on the net & decided to post some which will likely be used by yours truly. Hope you'll find them useful yourself.

Go to the position when you last closed the document
Shift + F5

Single line spacing
Ctrl + 1

Double line spacing
Ctrl + 2

1.5 line spacing
Ctrl + 5

Delete the current word under the cursor
Ctrl + Delete

Move a paragraph block
At any position in the paragraph, Shift + Alt then Up or Down arrow

Select content from current cursor position to the end of the current paragraph
Ctrl + Shift + Down Arrow

Monday, August 6, 2007

The mysterious "nextToken" smslib hack

The following hack was made to ATHandler.java in smslib for Java v3.0.2 (Beta)distribution in order to send SMS from a Java SE PC desktop application using the GSM modem feature on a mobile phone (E65, N95 or P990i) connected to the PC via Bluetooth.



I actually remarked the 2 highlighted lines as these were the source of a vague error when I ran JUnit tests in Eclipse. While I'm not exactly sure what I "fixed" (if you can call it that), said error disappeared and the SMS went through. Wohoo !! :D

FYI, the code I used was actually derived directly from the examples given with smslib but funny enough it took the hack above to get them working on all those 3 phones I tested.

Using FitLibrary with Patang

Recently I had to do a user acceptance test a.k.a. UAT, which involves testing a set of EJB3 beans running in JBoss 4.2.0.GA.

Decided to go for FitNesse & Patang combo, but to my horror Patang by default works with Fit as oppose to FitLibrary. The tests I'm running relies on special fixtures & features available only in FitLibrary.

After scouring through Patang's source code, I quickly locate the line where Patang calls Fit. Its actually inside FitServerRunner in method run. I changed the following line

   
FitServer fitServer = new FitServer();


to this:

   
FitServerBridge fitServer = new FitLibraryServer();


Then after rebuilding the Patang jars, I followed exactly the instructions as laid out in Patang's simple but effective manual. In no time, I was able to execute my UAT which utilises my deployed EJB3 beans in JBoss. Neat.

Now the hard part : coaching the QA team how to do modify a FitNesse WiKi. Sigh ....

BTW, the full source code for my modified FitServerRunner is shown below.

// START : code

package fitnesse.server;

import fit.Counts;
import fit.FitServer;
import fit.FitServerBridge;
import fitlibrary.suite.FitLibraryServer;

class FitServerRunner extends Runner {

public FitServerRunner(Parameters fitServerParameters) {
this.parameters = fitServerParameters;
}

protected Counts run(String[] params) throws Exception {
// FitServer fitServer = new FitServer();
FitServerBridge fitServer = new FitLibraryServer();

fitServer.run(params);
return fitServer.getCounts();
}

}

// END : code