Grails 运行时得到错误 Error starting Sun's native2ascii

在 Grails 运行的时候得到错误信息:Error starting Sun’s native2ascii

详细错误栈如下:[native2ascii] Converting 14 files from /home/sgross/myproj/grails-app/i18n to /home/sgross/.grails/1.4.0.M1/projects/myproj/resources/grails-app/i18n Exception in thread "Thread-11" : Error starting Sun's native2ascii: at org.apache.tools.ant.taskdefs.optional.native2ascii.SunNative2Ascii.run(SunNative2Ascii.java:67) at org.apache.tools.ant.taskdefs.optional.native2ascii.DefaultNative2Ascii.convert(DefaultNative2Ascii.java:54) at org.apache.tools.ant.taskdefs.optional.Native2Ascii.convert(Native2Ascii.java:294) at org.apache.tools.ant.taskdefs.optional.Native2Ascii.execute(Native2Ascii.java:251) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1105) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at groovy.util.AntBuilder.performTask(AntBuilder.java:255) at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:217) at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147) at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:171) at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at _GrailsPackage_groovy$_run_closure2_closure13_closure16.doCall(_GrailsPackage_groovy:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1105) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:226) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) at _GrailsPackage_groovy$_run_closure2_closure13_closure16.doCall(_GrailsPackage_groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1105) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1055) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885) at groovy.lang.Closure.call(Closure.java:405) at groovy.lang.Closure.call(Closure.java:399) at org.codehaus.groovy.grails.cli.api.BaseSettingsApi.profile(BaseSettingsApi.java:276) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1105) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1055) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:922) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885) at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1101) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1057) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:705) at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44) at groovy.lang.Script.invokeMethod(Script.java:78) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1120) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1014) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885) at groovy.lang.DelegatingMetaClass.invokeMethod(DelegatingMetaClass.java:149) at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:127) at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:162) at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44) at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1120) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1014) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145) at _GrailsPackage_groovy$_run_closure2_closure13.doCall(_GrailsPackage_groovy:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1105) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:226) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141) at _GrailsPackage_groovy$_run_closure2_closure13.doCall(_GrailsPackage_groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1105) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1055) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1069) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:885) at groovy.lang.Closure.call(Closure.java:405) at groovy.lang.Closure.call(Closure.java:399) at groovy.lang.Closure.run(Closure.java:483) at java.lang.Thread.run(Thread.java:679) Caused by: java.lang.ClassNotFoundException: sun.tools.native2ascii.Main at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:156) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:128) at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:43) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at org.apache.tools.ant.taskdefs.optional.native2ascii.SunNative2Ascii.run(SunNative2Ascii.java:51) ... 104 more 但是 Grails 的程序还是能启动,通过前台访问,你会得到一个服务器 503 内部错误的信息。

这是因为 JAVA_HOME 的变量没有设置正确。

你需要将这个变量设置到你 JDK 安装的路径下。

如果你的 JDK 安装在:/usr/lib/jvm/jdk1.6.0_25

那么你的 JAVA_HOME 也应该设置为:/usr/lib/jvm/jdk1.6.0_25 而不能设置为:/usr/lib/jvm/jdk1.6.0_25/jre