Grails tomcat root directory


In my production environment I have an apache server sitting at the root level ( ) and all urls that go to my app ( ) are routed to my grails web-app under tomcat through a tomcat connector.

I'm trying to reproduce this environment for local debugging. My problem is that my intellij project does not contain the apache resources. When I launch the debugger it goes to localhost:8080/myapp/. If I try to go to localhost:8080/index.html I get a 400 bad request response. I'm looking for a place where I can put the static html pages which would be equivalent to the tomcat webapps/ROOT directory, so I can drop a mypage.html there that would show up when I type localhost:8080/mypage.html.

It can either be part of the project/module configuration or it can be an external directory (something like the project directory in the grails installation). I tried all kinds of module configurations and I looked for the place IDEA uses as the root dir for the tomcat web app and couldn't get it to work. Any suggestions?


1 comment

This solved my problem:

In case the link doesn't work, it involves adding a script to the script directory:

I found the solution:

Add _Events.groovy file in project's script dorectory with following lines:
import org.apache.catalina.loader.WebappLoader

eventConfigureTomcat = {tomcat ->
        def imagesContextRoot = '/conextPathName'

        File appDir = new File('d:/localFolder');
        context = tomcat.addWebapp(imagesContextRoot, appDir.getAbsolutePath());
        context.reloadable = true

        WebappLoader loader = new WebappLoader(tomcat.class.classLoader)
        context.loader = loader



Please sign in to leave a comment.