• Home
  • RSS Feed
  • Log in

Grails Remoting with Hessian, Burlap and HttpInvoker
Posted by Erik Pragt at around evening time: September 25th, 2008

A short while ago, a collegue and I decided to write an application with Grails and Eclipse RCP. We choose Grails for the ease of development, and Eclipse RCP (in favor of Flex and Plain Old HTML) because we wanted to give our users a solid and native look and feel, for which Eclipse RCP works really well.

Since the Eclipse RCP front-end would actually be a remote front-end, we needed some kind of kind of communication between the client and the server. One of our first idea's was to use XML-RPC, which is pretty well supported in Grails, but it would force us to to do some mapping between our domain and the XML. Since we wanted to use the same domain classes is Eclipse as in Grails (by exporting the Grails domain to external domain jars), we opted for a different approach: Burlap/Hessian.

Burlap / Hessian

Burlap and Hessian are two protocols developed by Caucho. They serve the same purpose, but Burlap is XML, while Hessian is binary. While there is actually no reason the use Burlap, since Hessian is much smaller and thus faster, we choose Burlap, since it's easier to debug (it's plain XML after all). Okay, so there is a reason to pick Burlap after all..

In our Eclipse RCP application, we could use Spring, which has out of the box support for Hessian and Burlap. In Grails, we could use the Grails Remoting plugin, which also has support for Burlap and Hessian (and HttpInvoker and RMI, but more about that later). So, we just needed a little bit of configuration, connect them to each other, and it would work without any problems. Right? Right! In theory, it should work out of the box. In practice, there was Hibernate. And Proxies. And also some bugs....

Hibernate

Grails uses Hibernate. That's not a problem: in fact, it's great! Why re-invent the wheel when there's a powerful framework available? However, there are some issues when using Hibernate in combination with remoting. This is not Grails specific, but it did occur in our application, and since our application was a Grails application, it troubled us! The problem when using Grails, however, is that you might not suspect that all the collections you use are actually Hibernate collections. Normally, in a web application, it doesn't matter: Hibernate collections work like any other collection. When doing remoting, however, things change a little...

ClassNotFoundException for Hibernate Lists

Because you're using Hibernate, and you use remoting, you'll need Hibernate on the client side, because of the Hibernate Collections. Either that, or make copies of the objects yourself. While you're at it, you can make DTO's for it, which provide additional benefits. However, this does impose a lot of extra work (manually copying, extra classes to maintain, etc), so we'd rather not do this.

Lazy initialization exception / Proxies

A simple solution for the above is ofcourse to add to libraries on the client. Maybe not the best solution, but it's a solution anyway. However, when you do have the libraries at the client, you might run into Lazy Initialization Exceptions, because of Hibernate proxies. The easiest way to solve this is to agree on what to fetch, eagerly fetch all entities, and access only those relationships you agreed upon. There is (ofcourse!) a small problem with this approach: by default, Hibernate outer joins fetches 'only' 3 levels deep, but I needed 4. The recommended values are in between 0 and 3, but there isn't a lot of data to transfer, so I've set the hibernate.max_fetch_depth property in Grails to 4. This solved a lot! But, unfortunately, not everything...

Grails Bugs

As it seems, there are a lot of people using Grails to create web applications, but few of them use Grails for anything else, like remoting. There wasn't a lot of information to be found, except for the Wiki, and there was a slight problem: it didn't work. After 2 days of programming, I created more than 5 Jira issues on the remoting subject (see for example here, , or here. Most of the issues were blockers for Hessian and Burlap, or created a lot of noice hiding the real problem. So, after a couple of days without much progress, we had to talk..

Alternatives

After 2 days of remoting issues, we were at a T-junction, were we could either go left or right. Left would mean: look for completely alternative ways to do remoting, like XML-RPC or SOAP, and right would mean: investigate into our 2 alternative remoting options: RMI and HttpInvoker. After some discussion, we decided to give HttpInvoker a last chance: RMI is not firewall friendly, and XML-RPC/SOAP would mean a lot of extra work. And finally, we got some succes!

HttpInvoker

HttpInvoker allowed us to pass our tests! This meant it would be possible to retrieve a single object, a list of objects, and send information to the server! This worked great, all our tested passed! And we lived happily ever after.... or didn't we? I forgot to implement 1 more test: storing a complex object (like a Project class containing two Strings). Something with a ClassNotFoundException, even though we knew our classes were there...*sigh*. As a workaround, we didn't send any complex data, but only Strings, int, etc. I also created this issue here. While our application pretty much worked, it still had the complex object issue, which just didn't feel right. And after a week, our hero arrived: Peter Ledbrook made a patch for the issue, which worked immediately, which was really great!!

Conclusion

Despite all of our problems with Grails, the bugs, the remoting, with everything, it was a great learning experience. When all the bugs are fixed, Grails will make it's promise to be a high-productivity framework really come true. There's really no configuration needed, and when it works, it's great. I would certainly use something like HttpInvoker to do future remoting. It (at the moment) worked the best, can easily pass firewalls and is well supported (in Spring as well as in Grails). And above all, even though there was some frustration with the remoting plugin, it was really fun to develop the application!

Update

While writing this blog, I got some status updates on the rest of the issues, which seems all to be fixed right now! A new version of the plugin is even released! This part of the power of the Grails Community: no framework is 100% correct or bugfree, but it's great that there are people like Peter Ledbrook who care to make Grails even better. Thanks again Peter, your support is great!

  • Share/Bookmark

Tags: burlap, Grails, Groovy, hessian, httpinvoker
Filed under Grails, Groovy, Java | 7 Comments »



7 Responses to “Grails Remoting with Hessian, Burlap and HttpInvoker”



    Jawher Says:
    Posted at: September 26, 2008 at 12:34 am

    Hi,
    Thanks for sharing this.
    Could you please elaborate on the HttpInvoker section ? What problems exactly did it solve (in comparison with Hessian) ?

    Cheers,
    Jawher



    Erik Pragt Says:
    Posted at: September 26, 2008 at 9:56 am

    Hi Jawher,

    Thanks for the reaction. One of the problems we encountered problems with Hessian/Burlap when encountering Hibernate Collections. It seems Hessian/Burlap doesn’t know how to handle customized serialization for Hibernate Collections. One solution to this would be to copy all collections to new collections (for example you could copy your domain to DTO’s for example, and you solve two problems at the same time), but this costs some extra work, so we didn’t want to take that path.

    HttpInvoker didn’t have these problems, it just worked, probably because HttpInvoker uses Java’s own serialization, instead of a custom serialization.

    Also, because of Grails Remoting plugin issues at that time, it was quite hard to see what was working and what wasn’t: even when things worked, we got a lot of exceptions.

    So, in short, I would advise to check the new 1.0 version of the remoting plugin, and see what works for you. In the end, if you have only Java (compatible) clients, I would go for HttpInvoker: it’s fast, firewall friendly and can serialize all Java objects without problems.



    Jawher Says:
    Posted at: September 27, 2008 at 2:46 am

    Hi again,
    Thanks Erik for taking the time to answer my request ;)
    This will prove very useful as I’m planning to use Spring Remoting (via Hessian for now) for transferring Hibernate entities.

    Cheers,
    Jawher.



    Groovy on Grails : Grails Podcast Episode 67: Newscast for September 27 2008 (Sven Haiges & Glen Smith) Says:
    Posted at: September 28, 2008 at 10:20 pm

    [...] Grails Remoting wiht Hessian, Burlap and HttpInvoker [...]



    Jawher Says:
    Posted at: October 20, 2008 at 11:15 am

    Hi,
    Erik, I owe you one ! It indeed turned out that Hessian + Hibernate entities are not good friends … you end up getting very confusing exceptions (especially on the server side).
    Whereas when using Spring Remoting instead, it works like a charm.

    Cheers,
    Jawher



    Erik Pragt Says:
    Posted at: October 20, 2008 at 11:36 am

    Hi Jawher,

    I’m glad I could help! I already forgot which exceptions I got, but there were indeed many. Normally, when using Grails + Hibernate, this isn’t a problem since no remoting is involved, and you won’t notice all the proxies and Hibernate specific collections.

    So, when using remoting, I guess the easiest way out is indeed HttpInvoker!

    Cheers,

    Erik Pragt



    Peter Says:
    Posted at: April 18, 2009 at 11:11 am

    Thanks for this information!
    Especially the suggestion to HttpInvoker.
    And because of your blog I know the difference of all the remoting libraries in one sentence:
    RMI is not firewall friendly, and XML-RPC/SOAP would mean a lot of extra work.

    Great!



Leave a Reply

Click here to cancel reply.

Deployment automation for Java application running on Websphere, WebLogic and JBoss

Archives

  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009

Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India

Categories

  • Java (279)
  • Agile (109)
  • General (50)
  • Testing (42)
  • Performance (42)
  • Hibernate (36)
  • Scrum (33)
  • Podcast (31)
  • Architecture (31)
  • Spring (28)
  • SOA (24)
  • Maven (22)
  • Project Management (22)
  • Flex (17)
  • JPA (17)
    • JPA implementation patterns (13)
  • Eclipse (15)
  • Quality Assurance (14)
  • Middleware (19)
  • Frameworks (13)

Tag Cloud

    Semantic Web Grails Maven JavaOne esb Ajax Agile Awareness Workshop Closures qcon Agile Hibernate Scala product owner IntelliJ Xebia Architecture Java fitnesse Performance Testing Groovy Functional Programming SOA Lean Poppendieck Scrum Introduction to Agile XML Spring Seam
medicin depression buy phentermine without a perscription aricept generic hair loss help how do you prevent bone loss urinary tract infection symptoms viagra sex domination cialis viagra cures for throat infection buy sumycin acne care new medication for cancer treatment help for sleeping problems on-line pharmacies cure snoring medications to help clot blood what is aspirin buy zestoretic bronchitis vs pneumonia back pain muscle acne face medication muscle women pain behind knee fat blocker man health arthritis natural cure woman health women insomnia cheap phentermine online cats and irritable bowel syndrome buy cialis generic online nutritional diet for osteoporosis abnormal blood clots treatments for hair loss what is zyprexa dental whitening products impotence herbs drugs for diabetes allergy prevention buy canada levitra Mentax adhd in children hair loss in woman medicines for blood clot online imitrex viagra buy free dog products clindamycin drug how to stop hair loss chloramphenicol discount drug viagra what valium does permanent hair loss heart failure medicine avapro 150mg ordering viagra online food allergies order viagra online online viagra prescription carisoprodol mg improve your skin discount erectile dysfunction medication buy xanax online buy order viagra scabies teatments information allegra vitamine b1 diazepam breast cancer support free stop smoking cipro side effects ultram cheapest treatment attention deficit disorder discount vitamins supplements how to get viagra online synthroid buy cheapest cialis zyrtec online how to clear acne preventive osteoporosis immune stimulants what is hoodia On Line Viagra getting over the pain diflucan dosage health asthma online stores hair loss products blood clot drugs colon parasites hair loss products discount medicine pravastatin buy griseofulvin tablets order indomethacin dog health products how to take a beta-blocker diazapan is valium treating cold sores chronic pain drug what is osteoporosis stress drug tooth whitening lowering cholesterol naturally legality of buying cialis online order levitra treatment for insomnia cheapest cialis index depakote overdose alprazolam condom sales treatment of yeast infection xanax sales taking viagra after cialis how to control pain new birth control chest pain health prozac prescription blood clots viagra in mexico chlamydia pill cancer drugs cold flu drugs how do i order viagra online super viagra acyclovir medicine benadryl dosage erythromycin pregnancy buy contoured condom chronic muscle pain pet health dogs treatment attention deficit disorder dental teeth whitening asthma medicine free prescription drugs herpes drug diabetes treatment buy tooth whitening gel cheap fast valium generic levitra buy cheapest viagra online lopressor drug pharmacy drug prices ultram dosing treatments for bipolar disorder neurontin withdrawal parasite medication chlamydia tips for increasing breast size ways to enhance breast what is valium used for metformin tablet order birth control hair loss for men how does xanax work treatment hepatitis c rythmol cheap acai antioxidants nexium generic blood pressure pills levitra online no prescription Levitra Online medications on line motion sickness drugs bactrim online order roxithromycin nicotine where can i order viagra immune supplements buy erexin v bph prostate allopurinol xanax for depression drug new smoking stop cheap impotence drug generic cialis delivery new treatment for depression antibiotics for cat viagra china alternative medicine cholesterol viagra dose anxiety disorder treatment severe muscle pain treatment of cancer calcium carbonate penis enlargement without pill valium maximum dosage reasons for high blood pressure energy product breast enlargement info cheap effexor building your body wrinkle cream aricept dosage alpha blocker increasing female sex drive valium depression new pain meds no rx xanax drug trileptal mg imitrex avapro 150mg medicine drugs contraception female claritin pill medication for acne med orders buy viagra internet levitra effect treatment for blood clots order sominex buy creatine buy precose cheap viagra overnight lopressor drug body building info health drugs general health and medical what is diazepam eye infections in dogs online prescription pills diclofenac tablet new medication anxiety buy citalopram medication male enhancement enhancement fat blocker medicine for throat infection order cardizem about soma health remedies for dogs generic xanax cheap zyrtec for depression medicine viagra sex domination buy acne skin care product hypnosis help study cure vaginal yeast infection weight loss supplement program muscle pain in leg how to increase erection buy viagra what is cla augmentin doses gaining muscle mass health med online heart rate treatments lopressor drug dog ear canal phentermine without prescription viagra order online weight loss glipizide diabetes astelin generic fat blocker buy gel tooth whitening cheap wellbutrin online weight loss program buy antiox anti-biotics acne skin treatmen tramadole vpxl pill drugs affecting levitra immune system support augmentin hypothyroidism medication buy erexin v uy prescription medication without a prescription buy discount order osteo arthritis online buy pilocarpine cheapest place to buy phentermine parasite treatment impotence help body fat loss viagra herb alternative constipation supplements treatment dementia adhd and medications muscle spasm relief viagra online cheap relieve upper back pain stop hair loss discount viagra online menstrual cycle problems antifungal shampoo side effects ativan gabapentin medication where can i buy viagra diazepam buy soma online clonidine dosage viagra gel top hair loss fast antibiotics cure chlamydia skin fungal infections drug zofran give up smoking alternative medicine cholesterol sleeping help best online viagra scams prednisone 10mg viagra sex domination lotensin easy weight loss pain meds without prescription over the counter drugs new high blood pressure medic generic compazine cetirizine drug order phentermine best fat blockers woman enhancement supplement drug zofran buy precose new drug treatment for cancer how to increase fertility viagra in australia benadryl dosing buy alcoholism medications order l arginine buy diazepam generic for ativan ativan prescription drugs weight loss treatment for chest pain woman health where can i buy phentermine online skin fungal infection give up smoking viagra on line hoodia information how does osteoporosis occur buy viagra online buy alcoholism medications depakote overdose klonopin pill tetracycline capsules what is high blood pressure bladder control for dogs generic for lipitor glucophage online pharmacy gabapentin dosage treating yeast infections dog health info cymbalta anxiety cheap tramadol without prescription hydrea drugs used for cancer cure for high blood pressure alcohol and valium relief from constipation liver infection treatment cialis soft zantac medication help sleep problems all natural antibiotics order medication without prescription sleep problems free hypnotherapy gaining muscle mass cheap viagra order online natural help for pain how to buy viagra drug price celebrex information otc diuretic levitra 10 mg buy medicine online pets products relief foot pain cialis without prescription med care cheapest generic cialis rapid hair loss pain medications generic side effects meds without prescriptions cat anxiety buy simplicef natural cure arthritis effects of high blood pressure lowest price generic viagra how to get birth control new breast cancer drug buy topamax blood pressure meds when are beta blockers prescribed how to get pain meds order fosamax online viagra name order viagra viagra cialis cat's eye health how to relieve lower back pain treating ear infections diazapan is valium online pain doctors high blood pressure in elderly medication to stop smoking wellbutrin dosages diabetes blood sugar levels weight loss diet pill side effects of prescribed pain pills drug list high blood pressure buy cialis online in usa ultram cost how to help osteoporosis how to use clomid discount brand viagra wellbutrin cymbalta buy pills without a prescription buy pain medicine online tab tramadol depression symptoms treatment how levitra work hypertension medications beta blockers prevent premature ejaculation xanax interactions with other medicines purchase medicine on line does alli work xenical mexico prescriptions buy sumycin uy prescription medication without a prescription ambien cost methocarbamol effects cheap beta blockers cats bladder reduce cholesterol naturally metformin tablet scabies medicine breast enhancer pills body building over 50 order viagra cheap zestril medication how to buy prescription medications online pharma kamagra drugs depression ear infection symptoms big muscle controlling blood pressure pain meds and pregnancy buy diazepam without prescription skin allergies antibiotic zoloft buy weight loss nutrition program Buy Cialis breast increase meds without prescriptions blood clots medical edema treatment for flu best hangover remedy diabetes drugs