当我尝试从外部JAR使用库时,Grails 2.0中出现NoClassDefFound异常问题。Grails 2.0依赖NoClassDefFound问题
我已经检查过,声明的JAR是在创建的WAR内部的,也是griles dependecies-report不标记任何问题。
本地添加的JAR或从Maven回购下载似乎没有区别。我也尝试清理IVY缓存并清理Grails项目,但没有成功。
你有什么想法如何解决它?
BuildConfig.groovy(的一部分)
grails.project.dependency.resolution = {
inherits("global") {
// uncomment 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()
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 {
compile ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
runtime ( "javax:activation:1.0",
"javax:mail:1.0",
"com.google.gdata:gdata-core:1.0",
"com.google.gdata:gdata-client:1.0",
"com.google.gdata:gdata-media:1.0",
"com.google.gdata:gdata-youtube:2.0"
)
}
...
}
LibraryController.groovy
import com.google.gdata.client.youtube.YouTubeService
import com.google.gdata.data.youtube.VideoEntry
import com.google.gdata.util.ServiceException
class LibraryController {
private YouTubeService service
private static final API_URL = "http://gdata.youtube.com/feeds/api/videos/"
def index = {
service = new YouTubeService("app")
}
}
异常
Class
java.lang.NoClassDefFoundError
Message
Could not initialize class com.google.gdata.client.youtube.YouTubeServiceClass
java.lang.NoClassDefFoundError
消息 无法初始化类com.google.gdata.client.youtube.YouTubeService
我通常只使用“罐子-tf”检查的jar文件在war文件内部加倍确保包含类文件YouTubeServiceClass。 – 2012-04-07 09:00:19
你什么时候遇到这个错误?在运行时使用'run-app'? – Chris 2012-04-07 09:55:32
是的,我正在使用运行应用程序,并在进入库视图时出现异常。 – Simek 2012-04-07 11:44:19