Grails
  1. Grails
  2. GRAILS-6379

NotSerializableException: org.codehaus.groovy.grails.commons.DefaultGrailsApplication

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.3.2
    • Component/s: None
    • Labels:
      None

      Description

      If you inject grailsApplication into a domain class which is used in a flow,
      you get a NotSerializableException.

      A workaround is to use ConfigurationHolder instead. In this case you have to go without some properties you might want to use (from grailsApplication).

        Activity

        Hide
        Malte Huebner added a comment -

        Another workaround is to define it as a transient:

        transient grailsApplication
        

        Note that it's not sufficient to just add it to the "static transients"

        Show
        Malte Huebner added a comment - Another workaround is to define it as a transient: transient grailsApplication Note that it's not sufficient to just add it to the "static transients"
        Hide
        Graeme Rocher added a comment -

        I'm not convinced making GrailsApplication serializable is a good idea. You "workaround" of making it transient is the correct solution.

        Show
        Graeme Rocher added a comment - I'm not convinced making GrailsApplication serializable is a good idea. You "workaround" of making it transient is the correct solution.
        Hide
        Malte Huebner added a comment -

        I just noticed that the transient workaround is not the best solution as you have to inject the grailsApplication each time you need to access it. Otherwise it will end up in a NullpointerException. ConfigurationHolder is still the preferred way to handle this.

        Show
        Malte Huebner added a comment - I just noticed that the transient workaround is not the best solution as you have to inject the grailsApplication each time you need to access it. Otherwise it will end up in a NullpointerException. ConfigurationHolder is still the preferred way to handle this.

          People

          • Assignee:
            Unassigned
            Reporter:
            Malte Huebner
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development