Using Groovy/Grails in a legacy Java/JSP web app

I was fortunate enough to be able to start fresh with Grails. However, many people have asked me how to add Groovy and/or Grails to a legacy Java/JSP web app. Do people have experience or recommendations on how to best include Groovy and Grails into a large legacy application?

-------------Problems Reply------------

This IBM Developerworks article goes into detail about how to use Grails with your legacy database.

A tool that may help map legacy databases to grails domain objects is GRAG - the Grails Application Generator. It's a handy tool that helps generate the mapping classes for you.

A third option is to not use Grails for the gorm/domain layer. Instead, because it's works so well with Java, you can create services that call your existing legacy Java code for business logic and persistence.

I hope one of these approaches works for you.

One thing I've seen done is to use Grails as the Admin interface for an Enterprise Java application. It isn't exactly what you asked because there is no integration. There was just a set of requirements that were easily partitioned and developed very quickly in Grails. In reality they are separate applications but use the same data.

I'd start off by sharing the data model between the jsps and grails app (grails can run with plain Java classes and hibernate config, so if you are using hibernate already it shouldn't be hard to reuse the hibernate classes). Then I'd migrate each jsp/servlet as is to grails. If you are using spring already, it should make things easier since you can share the same application context.

Depending on how big the app is and other requirements, it might be better to rewrite the whole thing, specially if the legacy app doesn't use spring or hibernate.

I found this article that describes getting Groovlets and gsp's to work, specifying the web.xml updates and the jar files needed for the project.

I added the following jar files to my project and groovlets worked.


I don't have gsp's working yet.

I guess it depends on what is meant by "add grails/groovy" to an app - because grails is a full stack, and if by "add" you mean replace old with new, then it may be worth rewriting it.

Like others have said, Grails is a full stack, so adding Grails to an existing Java app might not be what you're looking for. Adding Java to an existing Grails app is trivial, however. And adding Groovy to an existing Java app might not be too hard either.

It depends a lot on the kind of Java app you're talking about. Grails is built on Spring MVC, Hibernate and similar standard Java technologies, so if your Java app is using all of that, it might easy to convert the app to Grails with some legacy Java code.

Category:grails Views:0 Time:2008-10-21
Tags: grails groovy

Related post

  • Java/JSP Web File Manager like CKFinder or KCFinder 2010-08-16

    I like CKFinder, but it is a commercial product. I also like KCFinder, but it works on PHP only, I need it to run on Java/JSP. Know any open source Java/JSP web file manager? Edit: The next best thing I found is this,

  • Migrating JSP web app to JSF 2011-07-19

    I am pretty new to java dev & JSF framework and as an exercise to get me up to speed I am migrating a JSP web app to a JSF2 structure. I was wondering if someone could suggest a best practice for doing this? Currently the JSP files are basically

  • Path related issue in Java EE web app 2012-02-25

    I have small Java EE web app developed in eclipse. I am using tomcat 6.0. In my application webcontent folder i have jsp folder and I have put all jsp files there.And I have css and JS folder which contains CSS and JS files.I have MVC design with sin

  • Injecting a Groovy Grails-service into a Java class 2011-11-22

    I have a Grails-service implemented in Groovy, which I'd like to inject into a Java class, in the web application. I know I can get the bean in Java via applicationContext.getBean("exampleService"), but the type ExampleService is unknown at compile t

  • Deploying Grails app inside another Java EE web app as ONE war file 2011-09-15

    I have existing Java EE web applications. And I also have a new Grails 1.3.7 application. The requirement is to embedded this Grails app inside an existing Java EE app and deploy it in one war file. Please let me know if that would be possible. -----

  • I've inherited a JSP/Java Servlet web-app, can I JUnit test this (in Tomcat) to get the code coverage? 2011-06-17

    Happy Friday! I assume somebody out there has a simple answer to this question and I'm hoping you read this post. I haven't really found the answer that I want searching the tubes & StackOverflow today. I've inherited a web-app (version 2.4) that

  • How to enumerate HTTP listeners from a Java EE web app 2008-12-02

    I have a web app with a web-based configuration UI. If the user accesses via HTTP, I want to alert the user that they should really use HTTPS and give them a link to click on to get to the HTTPS-prefixed URL. Now, this is pretty straightforward if we

  • Caching InitialContext and DataSource in a Java EE web-app 2011-02-19

    In the following Connector/J reference for JDBC/MySQL it suggests we cache the instances of InitialContext and Datasource. Would just making it a private static instance solve the caching? Shouldn't one have to be concerned with thread-safety (if at

  • Hosting java/j2ee web app on tomcat6 along with mysql5.1 database 2011-03-31

    I have a java/j2ee web application built using tomcat6 and at back endI have mysql 5.1 database, I have configured my server that an amazon ec2 instance and I have installed apache tomcat6 along with mysql5.1 and also java6. I have .war file of my pr

  • Protect Java Spring Web App with DMZ 2012-01-12

    Currently, I am designing my Java Spring + Web application deployment and planning to protect the internal resources with a DMZ. In many articles / tutorials I read, all the components (web/business/dao) are placed to a webapp file. I am planning to

  • Groovy/Grails Using WSClient to consume .net web service 2010-03-29

    I'm pretty new to both Grails/Groovy/Web services and i'm consuming a .net web service .. I have some code connects to the service using grails WS-client plugin : WebService webService def result = { def wsdl = ApplicationHolder.application.parentCon

  • Full path decleration for a file path used in java for jsp web app 2011-04-07

    I want to be able to have my paths work on any server not just my dev box. Right now I declear the full path of the file name as such on my local drive. filename = "H:\test\SourceCode\sample\src\file.txt" try { BufferedReader in = new BufferedReader(

  • Catching every exception in Java EE web apps 2009-08-12

    First, I am throwing run time exceptions for all unrecoverable exceptions, this causes these exceptions to travel up to the container, where I currently use an error page (defined in web.xml). In this error page is a scriptlet that invokes the logger

  • error when using http servlet - request/response in jsp web app 2011-06-28

    I have a function written in Java that uses http servlets- request/response, to connect to a local database... I want to use it in a jsp file. Please take a look at the initial portion of code below, and tell me if this can be used as it is. If it ca

  • Apache+Tomcat+jk: serving static resources in a Java EE web app 2011-11-04

    I recently installed Apache w/s + Tomcat and using jk was able to route requests from apache to t/c. The examples on the net are usually of the form: JkMount /*.jsp myTC We have several Java EE applications running on a single instance of tomcat (the

  • What are the basic components of a Java dynamic web app, and how JSF2.0 Facelets, and Myfaces relate to them? 2012-01-08

    I'm not a web developer, but I kinda know some basics, I wonna know what are Myfaces apache and facelets and how they relate to JSF2.0. I did my homework and wiki, googled them but it's still confusing. As far as I know for developing a Java based dy

  • Java Spring Web App - Database Access Exception 2011-01-10

    Hi iv been struggling with this error for some time and really cant figure out why its occurring , i have a web application that uses springs simpleJdbctemplate to access a database i can use this locally and it has been tested but when i deploy the

  • What's the best way to send scheduled e-mails from a Java-based web app? 2011-01-19

    I'm implementing a little web application using Java and the Wicket framework. Each user of the application has a list of events, each of which has a "due time." I would like to send an e-mail to the user when any of his/her events is due. How should

  • Java (maven web app), getting full file path for file in resources folder? 2011-08-25

    I'm working with a project that is setup using the standard Maven directory structure so I have a folder called "resources" and within this I have made a folder called "fonts" and then put a file in it. I need to pass in the full String file path (of

Copyright (C), All Rights Reserved.

processed in 0.079 (s). 11 q(s)