Grails tomcat root directory

Hi,

In my production environment I have an apache server sitting at the root level (http://mysite.com/... ) and all urls that go to my app (http://mysite.com/myapp/... ) 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?

Eran

0
1 comment
Avatar
Permanently deleted user

This solved my problem:

http://grails.1312388.n4.nabble.com/Add-virtual-directory-in-grails-tomcat-plugin-td2234448.html#a2234448

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
}



Eran

0

Please sign in to leave a comment.