Saturday, October 3, 2009

Grails and EJB

Read Jason Rudolphs article about grails and EJB a while ago. Grails + EJB Domain Models Step-by-Step. It is a nice article but not what I want.

However it seamed a little bit of inventing the wheel again to import the classes into Grails in the same package structure, and I also wanted some other things that EJB3 gave me.

  1. I want the EJB level to handle application rules. In that way, I can reuse the EJBs from other places as well
  2. I have information i two different schemas in Oracle and grails was not supporting more than one.
  3. I like "hit and run" session beans to provide services. which means that I use interface in the sessionbeans to provide CRUD and listing methods. 


So I started to elaborate with putting the EJB.jar file in Grails library folder to try it out. It worked out nice, the only thing I have to do is to put some lookup code and start using the session beans. I also get access to all model POJOs.

I like this approach because I can use grails rapid application development with the robustness of EJB3 without doing very much extra.

The downside is that as I am a little bit lazy and avoid writing too much code, is that I have to run it on the same glassfish and I have to copy the jar-file every time I change the interface. I also have to make a war of the grails application and run it on glassfish.

 /Peter

1 comment:

  1. Hi, I am new to EJB. Can you help me with the look up code. I tried looking up using resources.groovy but its giving errors.

    ReplyDelete