donalmurtagh / grails-flash-helper

Grails plugin that simplifies and standardizes the process of adding/reading messages in the flash scope
Apache License 2.0
0 stars 0 forks source link

groovy.lang.MissingPropertyException #3

Open djdenv opened 9 years ago

djdenv commented 9 years ago

the flashHelper variable does not seem to be injected into Controllers all the time. I especially see this when running through an IDE and the runtime refreshes, but have also seen it when running a simple run-app (outside of IDE). Here is a full stacktrace (note that this occurs with or without the linkedin profiler filter). I am running under grails 2.4.4

No such property: flashHelper for class: com.mycompany.gram.web.GraphicsController. Stacktrace follows: Message: No such property: flashHelper for class: com.mycompany.gram.web.GraphicsController Line | Method ->> 289 | update in com.mycompany.gram.web.GraphicsController


| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter . . . . in grails.plugin.cache.web.filter.AbstractFilter | 82 | doFilterInternal in com.linkedin.grails.profiler.ProfilerFilter | 1142 | runWorker . . . in java.util.concurrent.ThreadPoolExecutor | 617 | run in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run . . . . . . in java.lang.Thread

ghost commented 9 years ago

Can you provide some way for me to reproduce this issue?

djdenv commented 9 years ago

actually, I think it does have something to do with the profiler.

Create a new project and add the two plugins: compile ":flash-helper:0.9.9" compile ":profiler:0.5"

Create a controller: def index() { flashHelper.info "test message" }

Modify view: <flashMsg:msg key="info" sep=""/>

Run app to that view and you'll see the error I posted above. I don't know much about writing grails plugins so not sure if a fix would be in this project or profiler.

2015-01-11 22:16:13,738 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver - MissingPropertyException occurred when processing request: [GET] /testflash/test No such property: flashHelperInstance for class: testflash.TestController. Stacktrace follows: Message: No such property: flashHelperInstance for class: testflash.TestController Line | Method ->> 177 | doCall in ProfilerGrailsPlugin$_processController_closure4


| 101 | doCall in FlashHelperGrailsPlugin$_addFlashHelperMethod_closure7 | 180 | doCall . . . . . in ProfilerGrailsPlugin$_processController_closure4 | 6 | index in testflash.TestController | 198 | doFilter . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 82 | doFilterInternal in com.linkedin.grails.profiler.ProfilerFilter | 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor | 617 | run . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread

ghost commented 9 years ago

If you remove the profiler plugin, does the problem still occur?

djdenv commented 9 years ago

no. problem does not exist when we remove the profiler plugin.

ghost commented 9 years ago

On that basis, it seems more likely that the problem is with the profiler plugin, so I doubt I'll spend any time investigating this, given that there probably aren't too many apps using both this plugin and the profiler.

djdenv commented 9 years ago

I can understand that. I thought maybe it had to do with how the plugin was injected into the controllers. Again, don't know much about plugin development so was hoping for an easy (known) fix. Thanks.

ghost commented 9 years ago

The way that the flashHelper property is injected into controllers is pretty standard, so there's no obvious/easy fix that springs to mind. If you want to investigate yourself, the relevant code is the addFlashHelperMethod in this file