2012-11-30 167 views
5

當我嘗試運行我的Grails應用程序,我得到了以下錯誤:無法運行Grails應用程序?

Error 2012-11-30 15:35:57,948 [localhost-startStop-1] ERROR context.ContextLoader - Context initialization failed 
Message: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsServiceClass 
    Line | Method 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsServiceClass 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by InvocationTargetException: null 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by NoClassDefFoundError: com/lp/labs/scconnector/GitConnector 
->> 2427 | privateGetDeclaredMethods in java.lang.Class 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1791 | getDeclaredMethods in  '' 
| 303 | innerRun in java.util.concurrent.FutureTask$Sync 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by ClassNotFoundException: com.lp.labs.scconnector.GitConnector 
->> 202 | run  in java.net.URLClassLoader$1 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 190 | findClass in java.net.URLClassLoader 
| 306 | loadClass in java.lang.ClassLoader 
| 247 | loadClass in  '' 
| 2427 | privateGetDeclaredMethods in java.lang.Class 
| 1791 | getDeclaredMethods in  '' 
| 303 | innerRun in java.util.concurrent.FutureTask$Sync 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
| Error 2012-11-30 15:35:58,068 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsServiceClass 
Message: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsServiceClass 
    Line | Method 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsServiceClass 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by InvocationTargetException: null 
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by NoClassDefFoundError: com/lp/labs/scconnector/GitConnector 
->> 2427 | privateGetDeclaredMethods in java.lang.Class 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 1791 | getDeclaredMethods in  '' 
| 303 | innerRun in java.util.concurrent.FutureTask$Sync 
| 138 | run  in java.util.concurrent.FutureTask 
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
| 908 | run  in  '' 
^ 680 | run . . in java.lang.Thread 
Caused by ClassNotFoundException: com.lp.labs.scconnector.GitConnector 
    ->> 202 | run  in java.net.URLClassLoader$1 
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    | 190 | findClass in java.net.URLClassLoader 
    | 306 | loadClass in java.lang.ClassLoader 
    | 247 | loadClass in  '' 
    | 2427 | privateGetDeclaredMethods in java.lang.Class 
    | 1791 | getDeclaredMethods in  '' 
    | 303 | innerRun in java.util.concurrent.FutureTask$Sync 
    | 138 | run  in java.util.concurrent.FutureTask 
    | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker 
    | 908 | run  in  '' 

^ 680 | run . . in java.lang.Thread 

,這是我build.config文件:

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0) 
grails.project.class.dir = "target/classes" 
grails.project.test.class.dir = "target/test-classes" 
grails.project.test.reports.dir = "target/test-reports" 
grails.project.target.level = 1.6 
grails.project.source.level = 1.6 
//grails.project.war.file = "target/${appName}-${appVersion}.war" 

grails.project.dependency.resolution = { 
    // inherit Grails' default dependencies 
    inherits("global") { 
     // specify dependency exclusions here; for example, uncomment this to disable ehcache: 
     // excludes 'ehcache' 
    } 
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' 
    checksums true // Whether to verify checksums on resolve 

    repositories { 
     inherits true // Whether to inherit repository definitions from plugins 

     grailsPlugins() 
     grailsHome() 
     grailsCentral() 

     mavenLocal() 
     mavenCentral() 

     // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories 
     //mavenRepo "http://snapshots.repository.codehaus.org" 
     //mavenRepo "http://repository.codehaus.org" 
     //mavenRepo "http://download.java.net/maven/2/" 
     //mavenRepo "http://repository.jboss.com/maven2/" 
    } 
    dependencies { 
     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg. 

     // runtime 'mysql:mysql-connector-java:5.1.20' 
     compile 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r' 
     compile 'SC-Connector:SC-Connector:1.0' 
     compile 'AccountConnector:AccountConnector:1.0' 


     // runtime 
     runtime 'org.springframework.ws:spring-xml:2.0.4.RELEASE' 
     runtime 'org.springframework.ws:spring-ws-core:2.0.4.RELEASE' 
     runtime 'com.thoughtworks.xstream:xstream:1.4.2' 
     runtime 'org.springframework.ws:spring-oxm:3.1.0.RELEASE' 
     runtime 'org.springframework.ws:spring-oxm-tiger:1.5.10' 
     runtime 'com.sun.xml.bind:jaxb-impl:2.1.12' 
     runtime 'javax.xml.bind:jaxb-api:2.1' 
     runtime 'com.google.guava:guava:13.0.1' 
     runtime 'xmlpull:xmlpull:1.1.3.1' 

    } 

    plugins { 
     runtime ":hibernate:$grailsVersion" 
     runtime ":jquery:1.7.2" 
     runtime ":resources:1.1.6" 

     build ":tomcat:$grailsVersion" 

     runtime ":database-migration:1.1" 

     compile ':cache:1.0.0' 
    } 
} 

我認爲類是我的類路徑上,所以我不要認爲這是一個階級路徑問題。有誰知道如何解決它?

感謝,

+2

請提供更多信息。什麼是Grails版本?這是一個新項目?你已經嘗試過'grails clean'和'grails compile'嗎? –

+0

grails版本是2.1.1。我將這個項目複製到另一臺機器上,它工作正常。我嘗試清理並再次運行該項目,但仍顯示相同的錯誤。 –

+0

你可以發佈你的buildConfig嗎? 'com.lp.labs.scconnector.GitConnector'是一些私人類嗎?我沒有找到任何關於此的信息。 –

回答

7

是在lib目錄下的JAR文件com.lp.labs.scconnector.GitConnector?如果是這樣,運行grails compile --refresh-dependencies讓Grails將它添加到類路徑

+0

是的,它位於lib文件夾中的jar文件中。我運行這個命令,沒有任何改變 –

+0

你是從命令行還是IDE運行?爲了在STS中識別它,您需要運行Grails Tools | Refresh Dependencies來讓STS與Grails類路徑同步。 –

+0

我從STS運行刷新依賴關係,但不起作用。 –

1

也許你的問題可能源於其他原因,我有同樣的錯誤,並且在各處諮詢後,我建議做一個Grails-CLEAN,一切都解決了。