griffon编程错误:无法找到类注释

时间:2013-01-29 14:58:11

标签: griffon

我正试图抓住griffon / grails / groovy的项目。

我在编译时从我的Test1Controller.groovy文件中得到此错误:

[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 

这是我的控制器文件:

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')
            )
    }

}    

就像我说我是griffon / grails / groovy的新手 - 有人能帮我理解我似乎缺少的东西吗?

谢谢!

ironmantis7x

我做了下面建议的更改,现在运行时出现此错误: 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

如何签署应用以解决此错误?

这是我运行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

2 个答案:

答案 0 :(得分:3)

当您使用线程注释时,您应该在控制器上导入griffon.transform.Threading。

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')
            )
    }

}    

答案 1 :(得分:0)

默认情况下应该签署应用程序。调用run-webapp时,签名取自griffon-app/conf/BuildConfig.groovy。在开发中运行时,此签名是自签名的。例如,以下输出是在开发中运行webstart模式而不进行任何配置更改

Welcome to Griffon 1.2.0 - http://griffon-framework.org/
Licensed under Apache Standard License 2.0
Griffon home is set to: /usr/local/griffon

Base Directory: /private/tmp/test1
Running script /usr/local/griffon/scripts/RunWebstart.groovy
Resolving dependencies...
Dependencies resolved in 857ms.
Environment set to development
Resolving framework plugin dependencies ...
Framework plugin dependencies resolved in 1495 ms.
Resolving plugin dependencies ...
Plugin dependencies resolved in 807 ms.
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/classes/cli
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/classes/main
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/classes/test
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/test-classes
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/test-resources
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/resources
 [griffonc] Compiling 8 source files to /Users/aalmiray/.griffon/1.2.0/projects/test1/classes/main
 [griffonc] Compiling 3 source files to /Users/aalmiray/.griffon/1.2.0/projects/test1/classes/main
    [mkdir] Created dir: /private/tmp/test1/dist/webstart
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/resources/griffon-app/i18n
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/resources/griffon-app/resources
     [copy] Copying 2 files to /Users/aalmiray/.griffon/1.2.0/projects/test1/resources/griffon-app/i18n
     [copy] Copying 8 files to /Users/aalmiray/.griffon/1.2.0/projects/test1/resources/griffon-app/resources
     [copy] Copying 1 file to /Users/aalmiray/.griffon/1.2.0/projects/test1/classes/main
     [copy] Copying 11 files to /Users/aalmiray/.griffon/1.2.0/projects/test1/resources
     [copy] Copied 8 empty directories to 8 empty directories under /Users/aalmiray/.griffon/1.2.0/projects/test1/resources
Auto-generating a local self-signed key
   [genkey] Generating Key for development
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/groovy-all-2.0.6.jar to /private/tmp/test1/staging/groovy-all-2.0.6.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/griffon-rt-1.2.0.jar to /private/tmp/test1/staging/griffon-rt-1.2.0.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/slf4j-api-1.7.2.jar to /private/tmp/test1/staging/slf4j-api-1.7.2.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/log4j-1.2.17.jar to /private/tmp/test1/staging/log4j-1.2.17.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/slf4j-log4j12-1.7.2.jar to /private/tmp/test1/staging/slf4j-log4j12-1.7.2.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/jcl-over-slf4j-1.7.2.jar to /private/tmp/test1/staging/jcl-over-slf4j-1.7.2.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/jul-to-slf4j-1.7.2.jar to /private/tmp/test1/staging/jul-to-slf4j-1.7.2.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/griffon-swing-runtime-1.2.0.jar to /private/tmp/test1/staging/griffon-swing-runtime-1.2.0.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
      [jar] Building jar: /private/tmp/test1/staging/test1.jar
   [delete] Deleting directory /Users/aalmiray/.griffon/1.2.0/projects/test1/resources/griffon-app/resources
    [mkdir] Created dir: /Users/aalmiray/.griffon/1.2.0/projects/test1/resources/griffon-app/resources
     [copy] Copying 1 file to /private/tmp/test1/staging
  [signjar] Signing JAR: /private/tmp/test1/staging/test1.jar to /private/tmp/test1/staging/test1.jar as development
  [signjar] Warning: 
  [signjar] The signer certificate will expire within six months.
  [signjar] Enter Passphrase for keystore: Enter key password for development: 
     [copy] Copying 11 files to /private/tmp/test1/staging
     [copy] Copying 18 files to /private/tmp/test1/dist/webstart
     [copy] Copied 3 empty directories to 2 empty directories under /private/tmp/test1/dist/webstart
      [zip] Building zip: /private/tmp/test1/dist/webstart/test1-0.1-webstart.zip

在您发布的堆栈跟踪中注意到net.sourceforge.jnlp.LaunchException。您使用的是JDK提供的其他JNLP发射器吗?另外,运行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.6.0_37 (Apple Inc. 20.12-b01-434)
      OS: Mac OS X 10.7.5 x86_64