作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我在 Tomcat 7 上部署我的应用程序时,我在我的生产 Ubuntu 和开发 iOS 上都遇到了这个奇怪的失败。奇怪......而且我找不到导致问题的确切代码片段/:调用 $ grails run-app 工作得很好..
这是我的错误信息:
2013-03-04 16:47:27,966 [localhost-startStop-1] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: 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 p
arameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsC
ontrollerClass
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
... 6 more
Caused by: java.lang.NoClassDefFoundError: grails/test/GrailsMock
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
... 6 more
Caused by: java.lang.ClassNotFoundException: grails.test.GrailsMock
... 8 more
2013-03-04 16:47:27,991 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with na
me '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.DefaultGrailsControllerClass
org.springframework.beans.factory.BeanCreationException: 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 p
arameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsC
ontrollerClass
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
... 6 more
Caused by: java.lang.NoClassDefFoundError: grails/test/GrailsMock
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
... 6 more
Caused by: java.lang.ClassNotFoundException: grails.test.GrailsMock
... 8 more
2013-03-04 16:47:28,003 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing Grails: Error creating bean with name 'plugi
nManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.Runt
imeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
org.springframework.beans.factory.BeanCreationException: 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 p
arameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsC
ontrollerClass
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
... 6 more
Caused by: java.lang.NoClassDefFoundError: grails/test/GrailsMock
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.getDeclaredMethods(Class.java:1808)
... 6 more
Caused by: java.lang.ClassNotFoundException: grails.test.GrailsMock
... 8 more
还有我的构建配置:
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 "error" // 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()
mavenRepo "http://repository.codehaus.org/"
mavenRepo "http://repository.jboss.org/maven2/"
// 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 {
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'org.mongodb:mongo-java-driver:2.10.1'
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.20'
}
plugins {
compile ":mongodb:1.0.0.GA"
build ":tomcat:$grailsVersion"
runtime(":hibernate:$grailsVersion") {
export = false
}
test ":build-test-data:2.0.3"
compile ":crypto:2.0"
}
}
谢谢,
阿米特。
PS:链接到我在 grails-users 列表中的问题:http://grails.1312388.n4.nabble.com/Grails-fails-on-tomcat-with-missing-class-GrailsMock-tt4642038.html
最佳答案
问题是我在我的一项服务的顶部引用了@Mock 注释。 @Mock 注释显然不属于那里,而是属于测试类。这创建了对无法从 .war 包解析的 Grails 测试包的引用。
我可能在做 TDD 时把它搞混了/:
关于tomcat - Grails 在缺少类 GrailsMock 的 tomcat 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15207311/
当我在 Tomcat 7 上部署我的应用程序时,我在我的生产 Ubuntu 和开发 iOS 上都遇到了这个奇怪的失败。奇怪......而且我找不到导致问题的确切代码片段/:调用 $ grails ru
我是一名优秀的程序员,十分优秀!