当我尝试在OSX中从终端运行Grails时出现以下异常:
| Loading Grails 2.3.6
| Error java.lang.reflect.InvocationTargetException
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| Error at java.lang.reflect.Method.invoke(Method.java:597)
| Error at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:235)
| Error at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:263)
| Error Caused by: java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor2 cannot access its superclass sun.reflect.ConstructorAccessorImpl
| Error at sun.misc.Unsafe.defineClass(Native Method)
| Error at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
| Error at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
| Error at java.security.AccessController.doPrivileged(Native Method)
| Error at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
| Error at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:76)
| Error at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
| Error at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
| Error at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
| Error at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
| Error at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor.addRuleForModuleId(EnhancedDefaultDependencyDescriptor.groovy:135)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor$addRuleForModuleId$0.callCurrent(Unknown Source)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor.excludeForMap(EnhancedDefaultDependencyDescriptor.groovy:113)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor.this$3$excludeForMap(EnhancedDefaultDependencyDescriptor.groovy)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor$this$3$excludeForMap.callCurrent(Unknown Source)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor.<init>(EnhancedDefaultDependencyDescriptor.groovy:76)
| Error at org.codehaus.groovy.grails.resolve.EnhancedDefaultDependencyDescriptor.<init>(EnhancedDefaultDependencyDescriptor.groovy:80)
| Error at org.codehaus.groovy.grails.resolve.GrailsIvyDependencies.registerDependency(GrailsIvyDependencies.groovy:69)
| Error at org.codehaus.groovy.grails.resolve.GrailsIvyDependencies.registerDependencies(GrailsIvyDependencies.groovy:58)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| Error at java.lang.reflect.Method.invoke(Method.java:597)
| Error at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148)
| Error at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
| Error at org.codehaus.groovy.grails.resolve.GrailsIvyDependencies$_createDeclaration_closure1_closure3.doCall(GrailsIvyDependencies.groovy:117)
| Error at org.codehaus.groovy.grails.resolve.GrailsIvyDependencies$_createDeclaration_closure1_closure3.doCall(GrailsIvyDependencies.groovy)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| Error at java.lang.reflect.Method.invoke(Method.java:597)
| Error at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)
| Error at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:64)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
| Error at org.codehaus.groovy.grails.resolve.config.DependencyConfigurationConfigurer.dependencies(DependencyConfigurationConfigurer.groovy:150)
| Error at org.codehaus.groovy.grails.resolve.config.DependencyConfigurationConfigurer$dependencies$1.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
| Error at org.codehaus.groovy.grails.resolve.GrailsIvyDependencies$_createDeclaration_closure1.doCall(GrailsIvyDependencies.groovy:102)
| Error at org.codehaus.groovy.grails.resolve.GrailsIvyDependencies$_createDeclaration_closure1.doCall(GrailsIvyDependencies.groovy)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| Error at java.lang.reflect.Method.invoke(Method.java:597)
| Error at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
| Error at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
| Error at groovy.lang.Closure.call(Closure.java:411)
| Error at groovy.lang.Closure.call(Closure.java:405)
| Error at org.codehaus.groovy.grails.resolve.AbstractIvyDependencyManager.doParseDependencies(AbstractIvyDependencyManager.java:676)
| Error at org.codehaus.groovy.grails.resolve.AbstractIvyDependencyManager.parseDependencies(AbstractIvyDependencyManager.java:577)
| Error at org.codehaus.groovy.grails.resolve.DependencyManager$parseDependencies.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
| Error at org.codehaus.groovy.grails.resolve.DependencyManagerConfigurer.configureIvy(DependencyManagerConfigurer.groovy:157)
| Error at grails.util.BuildSettings.configureDependencyManager(BuildSettings.groovy:1281)
| Error at grails.util.BuildSettings.postLoadConfig(BuildSettings.groovy:1219)
| Error at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1075)
| Error at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
| Error at grails.util.BuildSettings$loadConfig$0.callCurrent(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
| Error at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1053)
| Error at org.codehaus.groovy.grails.cli.GrailsScriptRunner.loadConfigEnvironment(GrailsScriptRunner.java:249)
| Error at org.codehaus.groovy.grails.cli.GrailsScriptRunner.main(GrailsScriptRunner.java:210)
| Error ... 6 more
我可以从IntelliJ中运行得很好。我知道它与我的环境配置有关,但我还没有弄清楚到底是什么。我有什么想法吗?
我正在运行Java: java版&#34; 1.6.0_65&#34; Java(TM)SE运行时环境(版本1.6.0_65-b14-462-11M4609) Java HotSpot(TM)64位服务器VM(版本20.65-b04-462,混合模式)
OSX:10.8.4
答案 0 :(得分:0)
您是否正在导出JAVA_HOME,我知道在Linux上我每次都要使用grails命令行...
看看这里,也许尝试更新到jdk,因为它确实说jre ..(虽然不是mac专家) - 还有一些事情要尝试:
http://liberalsprouts.blogspot.co.uk/2012/12/how-to-install-jdk-7-and-set-up.html
echo $PATH
echo $JAVA_HOME
java --version
and
$JAVA_HOME/bin/java -version
看看它是否完全相同..我猜它会是,如果按照说明操作,可能会看到最新的jdk如何对待它。
弄清楚你的smartJ正在使用什么:
jps
3735
7588 GrailsStarter
7660 ForkedTomcatServer
7783 Jps
在我的情况下,如果我现在运行它的ggts:
lsof -p 7588|grep -i java|grep jdk|head -n 3
java 7588 mx1 txt REG 8,1 38568 18745123 /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java
java 7588 mx1 mem REG 8,1 71084 12982357 /usr/lib/jvm/java-6-openjdk-i386/jre/lib/i386/libj2pkcs11.so
java 7588 mx1 mem REG 8,1 85518 18745490 /usr/lib/jvm/java-6-openjdk-common/jre/lib/jce.jar
-p {process id}我把它输入脑袋以减少输出 - 但它让我知道它正在使用什么jdk - 也许你可以使用这种方法追踪正在发生的事情和导出等。