griffon

griffon programming error: unable to find class annotation


I am trying to get the hang of griffon/grails/groovy for a project.

I get this error at compile time from my Test1Controller.groovy file:

[griffonc] /home/ironmantis7x/griffon_projects/test1/griffon-app/controllers/test1/Test1Controller.groovy: 14: unable to resolve class Threading ,  unable to find class for annotation
 [griffonc]  @ line 14, column 5.
 [griffonc]        @Threading(Threading.Policy.SKIP)
 [griffonc]        ^
 [griffonc] 
 [griffonc] /home/ironmantis7x/griffon_projects/test1/griffon-app/controllers/test1/Test1Controller.groovy: 14: unable to find class 'Threading.Policy.SKIP' for annotation attribute constant
 [griffonc]  @ line 14, column 16.
 [griffonc]        @Threading(Threading.Policy.SKIP)
 [griffonc]                   ^
 [griffonc] 
 [griffonc] 2 errors                                                                                                             
Compilation error: Compilation Failed 

This is my controller file:

package test1

import griffon.util.GriffonNameUtils as GNU

class Test1Controller {

    def model

    def clear = {
            model.griffonClass.propertyNames.each { name -> model[name] = ''
            }
    }

    @Threading(Threading.Policy.SKIP)
    def submit = {
            java.swing.JoptionPane.showMessageDialog(
            app.windowManager.windows.find{it.focused}, 
            model.griffonClass.propertyNames.collect([]) {
                     name -> "${GNU.getNaturalName(name)} = ${model[name]}"
            }.join('n')
            )
    }

}    

Like I said I am new to griffon/grails/groovy - can someone help me understand what I seem to be missing?

Thanks!

ironmantis7x

I made the change suggested below and now I get this error when I run: griffon run-webstart -clean:

net.sourceforge.jnlp.LaunchException: Fatal: Initialization Error: Could not initialize application. 
    at net.sourceforge.jnlp.Launcher.createApplication(Launcher.java:778)
    at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:552)
    at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:889)
Caused by: net.sourceforge.jnlp.LaunchException: Fatal: Application Error: Cannot grant permissions to unsigned jars. Application requested security permissions, but jars are not signed.
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.setSecurity(JNLPClassLoader.java:312)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.<init>(JNLPClassLoader.java:232)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:357)
    at net.sourceforge.jnlp.runtime.JNLPClassLoader.getInstance(JNLPClassLoader.java:330)
    at net.sourceforge.jnlp.Launcher.createApplication(Launcher.java:770)
    ... 2 more

How do I sign the app to get past this error?

This is my configuration running griffon -version:

------------------------------------------------------------
  Griffon 1.2.0
------------------------------------------------------------

   Build: 11-Jan-2013 09:10 AM
  Groovy: 2.0.6
     Ant: 1.8.4
   Slf4j: 1.7.2
  Spring: 3.2.0.RELEASE
     JVM: 1.7.0_09 (Oracle Corporation 23.2-b09)
      OS: Linux 3.5.0-22-generic amd64

Solution

  • As you are using threading annotations you should import griffon.transform.Threading on your controller.

    package test1
    
    import griffon.util.GriffonNameUtils as GNU
    import griffon.transform.Threading 
    
    class Test1Controller {
    
        def model
    
        def clear = {
                model.griffonClass.propertyNames.each { name -> model[name] = ''
                }
        }
    
        @Threading(Threading.Policy.SKIP)
        def submit = {
                java.swing.JoptionPane.showMessageDialog(
                app.windowManager.windows.find{it.focused}, 
                model.griffonClass.propertyNames.collect([]) {
                         name -> "${GNU.getNaturalName(name)} = ${model[name]}"
                }.join('n')
                )
        }
    
    }