torsdag 18 oktober 2012

Making Jersey work with Google App Engine

I was looking for a way to get Jersey work in a Google App Engine application that I am working with. Things seems to work just fine with the local test server, but deployed in the production environment it fails miserably.

The answer to the problem wasn't easy to find at all, but after plenty of googling i found a this post that the answer I was looking for.

I will here summarize the steps in a bit shorter post and hope that it will make this solution a little bit easier to find for others.

The problem boils down to the dependency of the asm jar file. The new versions of the GAE libraries use asm-4.0.jar but Jersey still depends on asm-3.1.jar. There are some posts out there that suggest that you can remove the asm-4.0.jar and change the data nucleus version to v1. WARNING!!! Doing this messed my eclipse up totally. I never got it to work properly again and had to reinstall it and all the plug-ins!

What Harry Wye suggests on his blog is to repackage the jar files depending on asm-3.1 using Jarjar Links. This worked fine for me using version 1.3. 1.4 gave me a manifest attribute error. I am not terribly experienced in Java, so I don't know why this happend or what to do about it (if you know... please share it in a comment on this page), but trying 1.3 did the work for me.

To repackage the jersey server jar (which is the only one depending on asm), you first have to create a file (rule.txt) with this content:
rule org.objectweb.asm.**  org.objectweb.asm3.@1

Then run jarjar:

java -jar jarjar-1.3.jar process testrules.txt asm-3.1.jar asm-3.1r.jarjava -jar jarjar-1.3.jar process testrules.txt jersey-server-1.14.jar jersey-server-1.14r.jar

Now you can deploy Jersey with the modified jars along with asm-4.0.jar in your GAE application.

Good Luck

måndag 1 oktober 2012

DIY RS232 shield for the Olimex E407

My first hardware project with the E407 was to create an RS232 shield (they can be bought if you don't want to build it yourself). I used olimed own arduino proto shield. I happened to have a Maxim 232 driver circuit in my drawer, and also the five 1uF electrolytic capacitors needed to create this board.

First of all I discovered that the Olimex proto shield doesn't fit the board very well. I had to grind off one of the corners to make it fit with the power supply capacitors on the E407 board. A regular proto shield won't fit better... it seems like the capacitors aren't too well placed on the E407 board :-/

Since I am not very experienced in programming the STM32 processor I had to verify the construction with an AVR I had laying around and it seemed to work fine. I couldn't make it work with the E407 though.

I found out that the source I had downloaded from ST's site is designed for the Discovery board which has an 8 MHz external clock source. The E407 has a 12MHz clock. I had to generate a new system file with ST's excel tool. The patch can be found here.

I then compiled the example from Elias electronics blog, which seemed to work fine.

Good luck!