tags:

views:

367

answers:

3

I'm new to grails. I'd like to give it a whirl by implementing a new feature or two into an existing J2EE application. The current J2EE app is a fairly standard Spring MVC/Hibernate app running on Tomcat. Looking through the documentation, it looks like I should be able to leverage all of the current business logic that's written in Java.

I've only been able to find tutorials on creating new grails applications. Does anyone know of a tutorial for integrating with an existing J2EE app? If not a tutorial, any recommendations or suggestions on where to start?

Whether or not those features go live would depend on my experience with Grails and if I think it's worthwhile using it going forward. The goal would to either a) Decide Grails isn't for me (and not deploy grails). b) Decide it is for me, and all future development on this app would be in Grails with a full eventual port over.

+2  A: 

I'm afraid I don't know of any such tutorials, but my immediate thought would be that porting an application while also combined with learning Grails could be a big uphill.

I haven't done this sort of thing before, so these are just musings on how I might approach doing this..

Since GSPs are not analogous to JSPs and since Controllers in Java are statically typed, whereas Grails controllers have magic methods wired onto them, I would probably want to re-write those again in Grails from scratch since their transferability isn't obvious - the logic should transfer but the boilerplate of the old code isn't altogether necessary for the most part.

Maybe take a simple story/feature, keep the existing Services it uses and get them wired in via Spring in Grails. Then try making one for one copies of what you have in Java with corresponding Controller/GSP and Domains. That should give you some feel of what stuff you need to get off the ground for the port.

Your biggest struggle, from people who I have heard of doing this, might well be trying to re-use your existing hibernate stuff in Grails.

Just my tuppence, not so much a whole answer...

j pimmel
A: 

It depends on how you've written the j2ee app. You cannot drop it into the grails runtime and expect it to work with no tweaking, especially the 'controller' part of your app (since grails uses its own conventions for that). The UI, if its jsp, may be a bit better, since you can probably rename them to gsp, and have it work. tag libs works straight away, and normal java classes work straight away obviously. Hibernate objects may need tweaking - though i suppose it may just be easier to redo those using grails.

-my 2cents

Chii
+1  A: 

Insert Grails into an Spring app is not easily achievable, you can try to insert the old Spring app into a Grails app, and continue from that point.

Here you've some info 'bout using the hibernate mappings and java classes.

You also have to have to add the beans of the Sprint app to the Grails app. You can insert them into the ApplicationContext directly or use the resources.xml or resources.groovy.

HED