【问题标题】:Grails war command causing java.lang.UnsupportedClassVersionErrorGrails war 命令导致 java.lang.UnsupportedClassVersionError
【发布时间】:2009-12-02 17:08:50
【问题描述】:

我认为我最近没有对我的机器配置进行任何调整,但突然之间,在我执行了“grails clean”,然后是“grails war”之后,我无法构建我的项目,原因是: “java.lang.UnsupportedClassVersionError”。

JDK: 1.5.0_19 on MacOS 10.6
Grails: 1.1.1
Groovy: 1.6.5

这是我执行“grails war”时得到的结果:

Welcome to Grails 1.1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/local/grails-1.1.1

Base Directory: /Users/Robin/code/
Running script /usr/local/grails-1.1.1/scripts/War.groovy
Environment set to production
Warning, target causing name overwriting of name startLogging
     [copy] Copied 6 empty directories to 3 empty directories 
under /Users/robin/.grails/1.1.1/projects/wf/resources
    [mkdir] Created dir: /Users/Robin/code/web-app/plugins/ui-performance-1.2.1
     [copy] Copying 1 file to /Users/Robin/code/web-app/plugins/ui-performance-1.2.1
    [mkdir] Created dir: /Users/robin/.grails/1.1.1/projects/wf/classes
  [groovyc] Compiling 14 source files to /Users/robin/.grails/1.1.1/projects/wf/classes
  [groovyc] Compiling 262 source files to /Users/robin/.grails/1.1.1/projects/wf/classes
Compilation error: java.lang.UnsupportedClassVersionError: Bad version number in .class file

我有一些包含 java/part Groovy 类的 jar,它们是使用 Groovy 1.6.5 编译的。

我从哪里开始寻找导致此问题的原因?在 Grails 1.1 之前,我不记得框架有这么多问题。

【问题讨论】:

  • 部分问题可能是由于 MacOS X 10.6 没有或不支持 JDK 1.5(我知道你可以自己添加...)

标签: java grails


【解决方案1】:

AFAIK,Grails 1.1.1 不依赖于任何 JDK 6.x 功能,并且与 1.5 兼容编译。我假设您至少安装了一个使用目标 JDK 6.x 编译的插件。

最简单的解决方案是安装一个 JDK 6.x 并用这个做所有与 Grails 相关的事情。如果由于某种原因无法做到这一点,您可以使用http://mindprod.com/products1.html#JARCHECK 来识别“坏人”,尤其是。在 ~/.grails/1.1.1/projects/wf/plugins 中。然后使用 svn 检查“坏人”插件的源代码,并使用 JDK 1.5 自行编译。

【讨论】:

  • 感谢您指出这个工具。真是太棒了! (我需要继续使用 JDK 1.5)
猜你喜欢
  • 2017-11-24
  • 1970-01-01
  • 2017-08-23
  • 2014-07-03
  • 1970-01-01
  • 1970-01-01
  • 2013-05-18
  • 2018-03-06
  • 1970-01-01
相关资源
最近更新 更多