Grails
  1. Grails
  2. GRAILS-5683

doWithApplicationContext of plugins not being executed in run-war of the plugin project itself

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2 final
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Testcase included:
      yes

      Description

      [UPDATED - NOTE: This does NOT occur when run-war the application, only when run-war the plugin itself]

      I've found why Weceem appears broken in Grails 1.2 run-war deployments.

      doWithApplicationContext is not being run in WAR deployments.

      I reproduced this with a standalone plugin. This seems pretty critical. Is there a workaround? Has anybody actually deployed a war with plugins that use doWithApplicationContext successfully? This can't be that straightforward as I can't see how this can be completely broken - somebody would have noticed.

      I created a plugin that does nothing at all, but in the plugin groovy file has:

      def doWithApplicationContext = { applicationContext ->
             // TODO Implement post initialization spring config (optional)
             System.out.println "in doWithApplicationContext"
             throw new RuntimeException()
      }
      

      If you run-app it, it crashes and burns as you expect. If you run-war - nothing, it starts up.

      If you deploy this plugin into an clean grails app and run-app, it dies. run-war, it starts up.

        Activity

        Hide
        Russ Rollins added a comment -

        Was burned by this bug today during development of OpenAM plugin

        Show
        Russ Rollins added a comment - Was burned by this bug today during development of OpenAM plugin
        Hide
        Arthur Nogueira Neves added a comment -

        You know what is weird, the Quartz plugin use "def doWithApplicationContext" and I am pretty much sure that it is working normal for everyone.

        Also I have some applications in production running the war in tomcat and in Jetty, which both use Quartz just fine!

        I will try to simulate that! and let you know any thing!

        Show
        Arthur Nogueira Neves added a comment - You know what is weird, the Quartz plugin use "def doWithApplicationContext" and I am pretty much sure that it is working normal for everyone. Also I have some applications in production running the war in tomcat and in Jetty, which both use Quartz just fine! I will try to simulate that! and let you know any thing!
        Hide
        Arthur Nogueira Neves added a comment -

        Hi,

        actually I just installed the plugin in a clean app using grails 1.3.7, and even using run-war the app is breaking too!

        Actually the exception is another one, follow the exception that I am getting using 'run-war'

        INFO: Initializing Spring root WebApplicationContext
        LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException
        at org.apache.catalina.connector.Connector.start(Connector.java:1137)
        at org.apache.catalina.core.StandardService.start(StandardService.java:530)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:708)
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:286)
        at org.grails.tomcat.IsolatedTomcat.main(IsolatedTomcat.java:101)
        Error loading Tomcat: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException
        Exception in thread "Thread-5" java.lang.NullPointerException
        at org.codehaus.groovy.runtime.GroovyCategorySupport.hasCategoryInCurrentThread(GroovyCategorySupport.java:254)
        at groovy.lang.MetaClassImpl.getMethodWithCaching(MetaClassImpl.java:1128)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904)
        at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
        at groovy.lang.Closure.call(Closure.java:282)
        at groovy.lang.Closure.call(Closure.java:277)
        at groovy.lang.Closure.run(Closure.java:360)
        at java.lang.Thread.run(Thread.java:680)
        ')

        Show
        Arthur Nogueira Neves added a comment - Hi, actually I just installed the plugin in a clean app using grails 1.3.7, and even using run-war the app is breaking too! Actually the exception is another one, follow the exception that I am getting using 'run-war' INFO: Initializing Spring root WebApplicationContext LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException at org.apache.catalina.connector.Connector.start(Connector.java:1137) at org.apache.catalina.core.StandardService.start(StandardService.java:530) at org.apache.catalina.core.StandardServer.start(StandardServer.java:708) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:286) at org.grails.tomcat.IsolatedTomcat.main(IsolatedTomcat.java:101) Error loading Tomcat: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException Exception in thread "Thread-5" java.lang.NullPointerException at org.codehaus.groovy.runtime.GroovyCategorySupport.hasCategoryInCurrentThread(GroovyCategorySupport.java:254) at groovy.lang.MetaClassImpl.getMethodWithCaching(MetaClassImpl.java:1128) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:904) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886) at groovy.lang.Closure.call(Closure.java:282) at groovy.lang.Closure.call(Closure.java:277) at groovy.lang.Closure.run(Closure.java:360) at java.lang.Thread.run(Thread.java:680) ')
        Hide
        Burt Beckwith added a comment -

        Arthur, the bug isn't about installing the plugin in an application, it's about running the plugin itself as an application, i.e. running 'grails run-app' in the plugin project, not in an application that has the plugin installed.

        Show
        Burt Beckwith added a comment - Arthur, the bug isn't about installing the plugin in an application, it's about running the plugin itself as an application, i.e. running 'grails run-app' in the plugin project, not in an application that has the plugin installed.
        Hide
        Ivo Houbrechts added a comment -

        It is not only doWithApplicationContext, the entire xxxGrailsPlugin.groovy is skipped in war mode

        Show
        Ivo Houbrechts added a comment - It is not only doWithApplicationContext, the entire xxxGrailsPlugin.groovy is skipped in war mode

          People

          • Assignee:
            Unassigned
            Reporter:
            Marc Palmer
          • Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development