0

I upgraded my grails application to grails 2.3.2 from 2.2.4. I had previously used _Events.groovy eventConfigureTomcat() closure to establish an ajp connection from apache httpd mod_jk. When upgrading, I found that this is no longer supported, but the recommended approach is to implement org.grails.plugins.tomcat.ForkedTomcatCustomizer customize() method where I could establish ajp connector. See grails docs and search on ForkedTomcatConnector.

My problem is that the code is never invoked.

I implemented the ForkedTomcatCustomizer in the /src/groovy directory. Here is the code:

package org.grails.plugins.tomcat

import grails.util.Environment
import org.apache.catalina.connector.Connector
import org.apache.catalina.startup.Tomcat

/**
 * Forked tomcat customizer adds ajp connect to support apache ajp in dev env
 * from within IDE
 */
class ForkedTomcatCustomizer
{
    void customize(Tomcat tomcat)
    {
        println("In the ForkedTomcatCustomizer.customize() method")
        if (Environment.getCurrent() == Environment.DEVELOPMENT)
        {
            def ajpConnector = new Connector("org.apache.coyote.ajp.AjpProtocol")
            ajpConnector.port = 8009
            ajpConnector.protocol = "AJP/1.3"
            ajpConnector.redirectPort = 8443
            ajpConnector.enableLookups = false
            ajpConnector.setProperty("redirectPort", "8443")
            ajpConnector.setProperty("protocol", "AJP/1.3")
            ajpConnector.setProperty("enableLookups", "false")
            tomcat.service.addConnector ajpConnector
            println "Added ajp connector"
        }
    }
}

Anyone seen / resolved this?

Colin 't Hart
  • 7,372
  • 3
  • 28
  • 51
Bill Pfeiffer
  • 926
  • 8
  • 20
  • 1
    Have you enabled forked execution with `grails.project.fork.run=true`? – tim_yates Nov 08 '13 at 11:49
  • I had tried "grails.project.fork.run=true" on my full app when I first migrated it, but forgot to add this property to my test app. I just added the property to my test app and reran and it has no affect. – Bill Pfeiffer Nov 08 '13 at 13:51

1 Answers1

0

This seems to be a bug.

Refer to the code snippet below from TomcatDevelopmentRunner... the forkedClassLoader member is still null when invokeCustomizer is called (from the superclass constructor).. As you can see the NPE is swallowed and the process fails silently...

    private void invokeCustomizer(Tomcat tomcat) {
        Class cls = null
        try {
            cls = forkedClassLoader.loadClass("org.grails.plugins.tomcat.ForkedTomcatCustomizer")
        } catch (Throwable e) {
            // ignore
        }
        ...
Miller
  • 2,742
  • 22
  • 20