我已将我的应用程序更新到 Grails 2.3,但现在在启动和运行应用程序时遇到了一个非常令人沮丧的问题。我希望有人可以提供一些帮助。我们依赖于 doc4j,每次我去运行应用程序时,我都会得到一个“java.lang.ClassNotFoundException:org.docx4j.openpackaging.packages.WordprocessingMLPackage”。
在做了一些研究之后,我发现这个问题可能与我的类路径中没有 docx4j 的所有依赖项有关,但我已经检查并验证了此处列出的所有依赖 项 - http://dev.plutext。 org/docx4j/docx4j-2.5.0/ --在“Grails Dependencies”下:
属性-> JavaBuildPath ->库。
导致问题的包也在下面:
Grails 依赖项-> Docx4j-2.5.0.jar -> org.docx4j.openpackaging.packages -> WordprocessingMLPackage.class
这是我的堆栈跟踪:
| Loading Grails 2.3.0
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Error log4j:ERROR Property missing when configuring log4j: appName
| Running Grails application
| Error log4j:ERROR Property missing when configuring log4j: appName
2013-09-19 21:34:23,746 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 parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
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:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
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.DefaultGrailsControllerClass
... 5 more
Caused by: java.lang.reflect.InvocationTargetException
... 5 more
Caused by: java.lang.NoClassDefFoundError: org/docx4j/openpackaging/packages/WordprocessingMLPackage
at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
at java.lang.Class.getDeclaredMethods(Class.java:1810)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.docx4j.openpackaging.packages.WordprocessingMLPackage
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 7 more
2013-09-19 21:34:23,762 ERROR [context.GrailsContextLoader] Error initializing the application: 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.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 parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
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:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
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.DefaultGrailsControllerClass
... 5 more
Caused by: java.lang.reflect.InvocationTargetException
... 5 more
Caused by: java.lang.NoClassDefFoundError: org/docx4j/openpackaging/packages/WordprocessingMLPackage
at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
at java.lang.Class.getDeclaredMethods(Class.java:1810)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.docx4j.openpackaging.packages.WordprocessingMLPackage
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 7 more
如果您能给我任何帮助,我将不胜感激。谢谢。
- - -编辑 - - -
我正在添加我的 BuildConfig.groovy 以防提供任何额外信息:
/moving plugins dir to plugins directory under main project folder
grails.project.plugins.dir = 'plugins'
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn"
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment these to enable remote dependency resolution
// from public Maven repositories
mavenCentral()
mavenLocal()
//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.16'
}
plugins {
//----- for versions before 2.3 -----//
//compile ":hibernate:$grailsVersion"
//build ":tomcat:$grailsVersion"
// for versions after 2.3
//compile':hibernate:3.6.10.M3'
// moved from application.properties
compile ":cookie:0.4"
compile ":dojo:1.7.2.0"
compile ":help-balloons:1.4"
compile ":jsecurity:0.4.1"
compile ":p6spy:0.5"
compile ":searchable:0.6.4"
runtime ":hibernate:3.6.10.1"
build ':tomcat:7.0.41'
}
}