Jan 27, 2009

Maven Problem Solved

The Maven problem that I had the other day has been solved. It was simple a matter of configuration for ProGuard. The problem is described in more detail here. Thanks Karsten for helping me out with this problem.

This brings me to the next topic; there is a new snapshot release of Microlog available. The changes are:
  • Added the ability to print the absolute time with the PatternFormatter. The %d is used for this purpose, to be compatible with Log4j. The date format specifiers are also available; ABSOLUTE, DATE, ISO8601.
  • The ByteArrayOutputStream that is used for creating log data in the RecordStoreAppender was closed, which is not necessary. This has now been changed.
  • Added some useful printouts for the RecordStoreAppender and the RecordStoreLogViewer.
I think that the first item is the most interesting one. The PatternFormatter is almost as capable as its Log4j counterpart. I am looking forward hearing from developers out there, giving feedback about this release.

Please download.

Jan 22, 2009

Maven Problems

I still have not found a solution to the NoClassDefFoundError-problem, but a workaround. The workaround is to execute the code in NetBeans, or another IDE than Eclipse. When doing a release, I encountered yet another problem. This time it was Maven that issued a build error. The output from Maven looks like this:

....
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper exte
nds or implements program class cldcunit.runner.BaseTestCaseHelper
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.TestMethod
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.TestMethod
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.TestMethod
[proguard] Warning: library class cldcunit.runner.ReflectionTestCaseHelper depe
nds on program class junit.framework.Test
[proguard] Warning: there were 5 instances of library classes depending on prog
ram classes.
[proguard] You must avoid such dependencies, since the program classes
will
[proguard] be processed, while the library classes will remain unchang
ed.
[proguard] Error: Please correct the above warnings first.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Obfuscation failed (result=1)

What does this mean? To me it seems like ProGuard has found a problem with CLDCUnit. So this leaves me with still another issues that delays my release of a new Microlog version. Not good!

Jan 20, 2009

NoClassDefFoundError in Eclipse MTJ

Yesterday I started to implement a new feature in the PatternFormatter for Microlog. A user wanted the ability to print the absolute time. The first implementation was pretty rudimentary, the only available format was the default format used in Log4j's PatternLayout. It worked but today I wanted to improve it. I had planned a snapshot release after that. But I ran into unforeseen troubles. When trying to execute the example MIDlet to try it out, I get the following message in the console window;

java.lang.NoClassDefFoundError: net/sf/microlog/Appender
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)

Notice that this is not a classic ClassNotFoundException problem. A ClassNotFoundException is always quite easy to fix. You have to check that you have your classpaths in order. This is something that a every Java developer has to learn to fix, otherwise you do not survive as a Java developer for long. But to fix the NoClassDefFoundError is harder. It basically means that your environment has found the class, but there is something fishy with the bytecode. In this case I have no clue. Is this a compiler problem? Is it a problem with the preverifier? I have done Googling on it, but did not find any relevant answers. Is a problem with Eclipse MTJ? Do you have any clue?

So bear with me, there is a new Microlog snapshot release on its way. I will have to fix the above problem before releasing the code. For the impatient developer, the code is available in the Microlog source repository.

Jan 17, 2009

The Microlog Modules

The Microlog project started out its life as a small set of classes. Since then Microlog has grown and transformed into several modules. The reason is of course to make it easier for the developers using Microlog and to keep the core small. The downside is that a new user of Microlog might get confused. If you feel that you fall into that category, please read on. For those of you that already are hooked on Microlog, I hope that this will give you the overview that you been longing for.

The Microlog project consists of these modules:
  • Microlog Java ME library
  • Microlog Instrument
  • Microlog Instrumentor Example
  • Microlog Java ME library Examples
  • Microlog Servers
The Microlog Java ME library is where all the goodies are. Here you will find the logging classes. If you choose to only download one module, this should be the one. The Microlog ME library examples module contains example MIDlets that demonstrate how to use and setup Microlog.

Some users complained about the inability to log the name of the method and the line number where the actual logging took place. The reason for this is that Java ME with the CLDC configuration does not support reflection. Our workaround is to instrument the bytecode before you create your JAR file. The Microlog Instrument module contains a tool for inserting the relevant information. If you wonder how to use it, you could download the Microlog Instrumentor Example module. If you are content with only logging the name of the class, you could use the Logger.getLogger(Class clazz) method to create your Logger instance. This way you get a named logger that has the same name as your class, that is the fully qualified classname. This could be used in conjunction with the Microlog instrumentor, since they are not mutually exclusive. It should be noted that the size of the classes grows when instrumenting them. It is a matter of taste and need that decides when to instrument your classes. One solution could be that you instrument your classes during development, but skip the instrumentation when creating the final jar. This adheres to the Microlog philosophy, we bring you the tools and you select the parts you like.

Last but not least, there is the Microlog Servers module. This contains example code of several servers. I prefer to write examples since the servers are rather simple, although I believe that they are just enough for most people. The output is printed to the standard output. If you start the server from the command line, the output is shown in the command shell. Today there are two servers available; the Bluetooth server and the socket server. The socket server could be used for normal sockets, as well as SSL sockets. Both are intended to be executed on a PC. If you need to execute a Bluetooth server on a phone, there is also a MIDlet version available in the Microlog Java ME library module.

I hope that this guide gave you a good insight into Microlog. Feedback is very welcome.

Jan 13, 2009

A Little Bit Off Topic - Nintendo Wii etc

Yesterday I was back in business after the holidays. Before the holidays I was convinced that I would have time to do a lot of work on my open source projects. You could guess how wrong I was!

My son wished for a Nintendo Wii console from Santa. Since he has been a good boy, at least from time to time, he got one. Have you heard about the Wii? The concept is as genius as simple, an accelerometer included in each remote. The accelerometer is used to control the movements on the screen. For example, you could use it as a racket in a game of tennis. For my son that is 6 years old, this is much simpler than using an ordinary remote control. We have one older platform, but that is not used very much. If it used by my son, he uses the buzz buttons. A matter of fact, it makes it easy for the rest of family as well. No need to remember some odd key combination to do a punch. Just do a punch in the air to do a boxing punch on the screen. The funny thing is that by the end of the holidays, the whole family was really hooked on Wii.

For the most part we played the supplied Wii sports, but some other games was played as well. My son spent several hours discovering the Star Wars world in "LEGO Star Wars The Video Game". The "LEGO Batman: The Video game" was also played a lot. If you have a kid around the age of 6-10, I could really recommend these games. To be honest, I also liked these games and spent countless hours playing them with my son. When I was alone I played "Battalion Wars II". This is similar to the Battlefield games, but without one drop of blood. The graphics is a little bit cartoon like and with a twist of humor, which I appreciate. At first a was a little bit skeptical about the game controls, you use the built-in IR pointer to point at target on the screen. It takes some practice to get used to the IR pointer, but once you get it, it is easy to use. To help you in this game, you have a locking button. When this is pressed, the target is locked. If you are not dead on target, the aim point snaps to the target. I have only played the first couple of parts in the campaign, but so far I like this game.

That is all for now. I hope to be up to speed within a couple of days with my blog, the open source projects etc. If not, I suppose that I will be playing some Wii.