griffon programming error: unable to find class an

2019-07-13 03:52发布

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

标签: griffon
2条回答
欢心
2楼-- · 2019-07-13 04:18

Application signing should happen by default. When run-webapp is invoked the signature is taken from griffon-app/conf/BuildConfig.groovy. This signature is a self-signed one when running in development. For example, the following output is form running webstart mode in development without any configuration changes

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

Couldn't fail to notice net.sourceforge.jnlp.LaunchException in the stack trace you posted. Are you using a different JNLP launcher other from the one provided by the JDK? Also, what's the output of running griffon -version? Mine is

------------------------------------------------------------
  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
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-13 04:40

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

}    
查看更多
登录 后发表回答