Grails XFire + Flex (flex xfire Error #2032: Streamfout.)

I’m building a small application for myself. It will manage my orders and invoices. Reason I’m doing this is mainly to try out new stuff. I thought I’ld try out a Grails soap backend with a Flex frontend. Doesn’t sound to difficult, right? Well I ran into a problem and it took me some time before I found a solution.

I had created a simple webservice that would return all my orders. Something like this piece of code

class PurchaseOrderWebService {

boolean transactional = true
static expose=[‘xfire’]

PurchaseOrder findById(Long id){
return PurchaseOrder.get(id)
}

PurchaseOrder[] findAll(){
println(‘listing all’)
return PurchaseOrder.list() as PurchaseOrder[]
}

PurchaseOrder save(PurchaseOrder order){
return order.save()
}
}

Pretty simple don’t ya think. This is now accessable as a soap webservice. In Flex I used the generator to generate all my stubs. The Flex code would look something like this

public function loadData():void
{
Alert.show(“test5”);
var service:generated.webservices.PurchaseOrderWeb = new generated.webservices.PurchaseOrderWeb();
service.addEventListener(FaultEvent.FAULT,errorHandler);
service.addfindAllEventListener(findAllListener);
service.findAll();
}

public function findAllListener(e:generated.webservices.FindAllResultEvent):void
{
this.orderDG.dataProvider = e.result;
}

Here I show the alert so I’m sure I’m not using a cached version of the SWF. However doing this returns a Error #2032. Why? Well I don’t know. I tried using the soap service from another programming language (c#) and it worked fine. After much googling I finally found the answer. For some reason Flex doesn’t like it when you don’t supply an argument to the soap call. The piece of code that finally did the trick looks like this

Grails

class PurchaseOrderWebService {

boolean transactional = true
static expose=[‘xfire’]

PurchaseOrder findById(Long id){
return PurchaseOrder.get(id)
}

PurchaseOrder[] findAll(String dummy){
println(‘listing all’)
return PurchaseOrder.list() as PurchaseOrder[]
}

PurchaseOrder save(PurchaseOrder order){
return order.save()
}

}

Flex

public function loadData():void
{
Alert.show(“test6”);
var service:generated.webservices.PurchaseOrderWeb = new generated.webservices.PurchaseOrderWeb();
service.addEventListener(FaultEvent.FAULT,errorHandler);
service.addfindAllEventListener(findAllListener);
service.findAll(“test”);
}

public function findAllListener(e:generated.webservices.FindAllResultEvent):void
{
this.orderDG.dataProvider = e.result;
}

Strange bug if you ask me. I hope this get’s indexed and it will help other people facing this problem.

mount within gnome access it using terminal?

I sometimes have to connect to a windows share from my linux box. I do this using samba (ff course). However when I start a gnome terminal and I want to go on that mounted share, I don’t see it. If I use the commandline smbmount I can access it. Does anybody know how you can achieve this? I find it strange that I have to mount it twice, once from inside gnome and once from inside my gnome terminal. Should be a solution no?

Flex + Grails

At the moment I’m working on a publishing thing. The frontend is build in Flex and the backend is build in Grails. I have to say this is a super combination. I can leverage all my Java skills in the backend, I can use the advanced graphs that come default with Flex and best of all. If I don’t need to stop start my application server. I change my code, save F5 and voila my new code is running. Reminds of when I did a lot of php development (still do some, but not that frequent). Okay some of you may argue that Flash is not opensource, but Flex and grails are opensource.

If you need to have graphs in your application, you should really check out Flex. The Flex builder app is not free but there are opensource things (ant build files) that let you generate applications from your Flex code. I’m getting more and more convinced that Flex is the way to go if you do enterprise development. Some may argue that we should use domain driven development, but what prohibits you from doing this with Flex??

But like always choose the right tool for the right job.

Upgrade Ubuntu 9.04

A couple of days ago I upgrade my ubuntu to the latest release (9.04). Like always I had trouble afterwards. After upgrading everything seemed to work fine. I opened firefox and didn’t see any flash … strange. I checked with dpkg and there it said flash-non-free installed. Hmmm very odd suddenly my 2 screens (dual desktop) fell out and came back, even more strange. A couple of seconds later they again fell out and I was back at the gdm login screen. What the f**** I logged back in and started investigating my flash problem. Suddenly my computer hang. I didn’t have the time to investigate so I rebooted and went to bed.

The next day I came back from work and the system was still up and running. My first guess was that the crash had something to do with the X system. I logged in from a remote system and started tailing almost all the log files. I tried to reproduce the system and suddenly again it crashed. I checked the logs but nothing came up after rebooting and rechecking the logs still nothing. As a last resort I downgraded my proprietary nvidia driver and after this my system was stable again. Anybody having/had the same problems? What fixed it for you?

Selenium webtesting

For my current project I already have a lot of testcases (off course). In the beginning I also had some webtests but these weren’t really what I wanted. Today I finally succeeded in performing full roundtrip testcases with Selenium. I first recorded some testcases with the IDE plugin, I exported these testcases to Java and started experimenting with the code.

After a short coding marathon I had created several tests. A user logs in, performs some actions and logs out. Another user logs in, picks up the actions from the first user and completes the actions. A real ping pong game like the real application should work. I see the firefox windows open, fields getting filled,buttons getting clicked,… it’s as if a user is really performing all these actions on my computer.

I still have to integrate this with my Hudson builds. I’m not yet 100% sure how this will work as my Hudson is running inside a Tomcat that’s running as the System user. This might cause some problems, maybe I should run my tomcat from the console …? I’ll keep you posted.

I actually wonder how other environments like dotnet,php,ruby perform these tasks? Do they have a build in tool for performing reall web tests?

Fonts in Gnome

A couple of weeks ago I complained about the font size in gnome. After some fooling around in my menu settings I found a small little tweak.

System -> Preferences -> Appearance

You’ll see a dialog with a couple of tabs. Choose the Fonts tab and click on the Details button. I changed my Resolution to 84 dots per inch. I’m using a dual 24″ TFT setup and looks much nicer. The fonts look more crispy and the whole desktop just feels nicer to play with.

On a side note for the hosting and colo side of our company we bought a new NAS. I asked the reseller to install an Openfiler on it. It is now fully configured and is already being used to backup all of our systems. I first had some trouble with the setup of the LDAP but now it works. So if you need a free nice NAS solution go ahead and check it out.

remote sessions using NX

I regularly use NX to do remote desktop style Linux. Normally I use gnome as my main desktop manager. I hadn’t used KDE for a couple of years. I thought, why not give it a go. So I installed it and logged in from my NX session. My first impression was really good. I like gnome for my desktop but it’s not so nice over NX. The fonts are to big, the cursos get’s screwed up (can’t change it with themes either).

Using KDE it all looks better. My fonts are smaller but clearer, my mouse cursor is better. It does seem somewhat smaller. I used it on my main desktop and there it’s ok, but I’ll stick to gnome there. Probably for some appz I’ll start using the KDE version. (e.g. The remote desktop admin looks much nicer).

Anybody else got the same experience with NX ?

Zarafa + z-push + Iphone

In the past I already blogt about connecting my Iphone with my Imap using z-push. This always worked for a couple of hours and then suddenly it died. No idea why my Iphone stopped performing requests, the guy from zarafa didn’t know eighter. Now I’ve setup the full Zarafa with z-push. It has been running for almost a week and it’s still working and syncen every minute. I had expected my battery to be dead within a day, but it lives for almost 2 days. Not good, not at all but I had expected worse.

The nice thing is that I now have my contacts,calendar and mails synced.  Check it out, they’re really cheap in comparison to ms solution and if you have an active sync capable phone you can sync everything. Pretty nice 🙂 In the next release they even support blackberry. This should be a pretty good alternative for companies who already invested a lot of money in microsoft and want a migration path to the opensource world.

If only there was a good opensource alternative for the IPhone. Google phone is not available in Belgium yet and the openmoko just seems to be leaping behind.

Hudson

For a project at a client I used to use Cruise Control. This worked but was not ideal (it was running in a dedicated vmware on my own computer.) Sometimes I had to shut the vm down to gain the resources.

I heared about Hudson on the Javaposse. I installed it and configured it. Now every day at 8 o’clock it performs a checkout and performs the unit tests. I could have installed the SCM plugin off course. But the database could change without the SCM being updated so this option was better imho.

I have to say Hudson is much simpler to setup and configure compared to Cruise Control. It’s just a webapp that you have to deploy (on Tomcat in our situation). I created a project using the build in web gui and everything was up and running. For Cruise Control I had to perform some stuff in XML also easy, but this was even easier 🙂

If you plan on doing continuous integration and aren’t using Hudson, you should check it out. I still have to do the Selenium webtest but that’s for after the next release. 🙂

Groovy and Grails

During my vacation I did a bit of development in Grails. I have to say I’m pretty pleased with the result. I did a small app for creating offers,orders and generating an invoice from these. I migrated my old postgresql data to the new mysql schema.

I know there are already opensource tools out there who do this. But I wanted to try this technology to build something. Why not something I could use myself.

Grails uses the same ideas as rails but uses the Groovy language. This language leans more towards Java (and actually is just an extra layer on top of Java). I have to say that once you get the hang of it you’re actually more productive using this technology. But off course there is a downside. If you have an existing database with data you could have problems mapping these things using Grails. Grails uses Hibernate underneath but some things are not straight forward, e.g. if you want to use the scaffolding feature make sure your domain class has an id property otherwise you could get into trouble. This looks straightforward but some of my classes had an invoiceId instead of id property.

For the next stuff I’m going to build a Flex frontend. I already did some appz using Flex but there’s still plenty of stuff to learn and the opensource components are growing every day so …