google app engine/java上带有grails时区选择标记的IllegaAccess异常

google app engine/java上带有grails时区选择标记的IllegaAccess异常,java,google-app-engine,grails,timezone,Java,Google App Engine,Grails,Timezone,有人在GAE/J上使用过grails timeZoneSelect标记吗?我在AppEngine上遇到了下面的错误。我知道反射是不允许的,但出错的行似乎在调用一个简单的公共函数(inDaylightTime)?有人知道如何解决这个问题吗(除了硬编码的时区列表) 谢谢 Uncaught exception from servlet org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processi

有人在GAE/J上使用过grails timeZoneSelect标记吗?我在AppEngine上遇到了下面的错误。我知道反射是不允许的,但出错的行似乎在调用一个简单的公共函数(inDaylightTime)?有人知道如何解决这个问题吗(除了硬编码的时区列表)

谢谢

Uncaught exception from servlet org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Error executing tag : org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag : java.lang.IllegalAccessException: Reflection is not allowed on public boolean sun.util.calendar.ZoneInfo.inDaylightTime(java.util.Date) at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97) at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35) at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238) at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76) at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135) at com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:235) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5235) at com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5233) at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24) at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:363) at com.google.net.rpc.impl.Server$2.run(Server.java:838) at com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56) at com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan(LocalTraceSpanBuilder.java:536) at com.google.net.rpc.impl.Server.startRpc(Server.java:793) at com.google.net.rpc.impl.Server.processRequest(Server.java:368) at com.google.net.rpc.impl.ServerConnection.messageReceived(ServerConnection.java:448) at com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:319) at com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:290) at com.google.net.async.Connection.handleReadEvent(Connection.java:466) at com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:759) at com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:205) at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:101) at com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:251) at com.google.apphosting.runtime.JavaRuntime$RpcRunnable.run(JavaRuntime.java:394) at java.lang.Thread.run(Unknown Source) Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag : org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag : java.lang.IllegalAccessException: Reflection is not allowed on public boolean sun.util.calendar.ZoneInfo.inDaylightTime(java.util.Date) 来自servlet的未捕获异常 org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException:错误处理GroovyPageView:错误执行标记:org.codehaus.groovy.grails.web.taglib.exceptions.GrailStageException:错误执行标记:java.lang.IllegalAccessException:不允许在公共布尔值sun.util.calendar.ZoneInfo.inDaylightTime上反射(java.util.Date) 在com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:97)上 位于com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35) 位于com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43) 位于com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:238) 位于com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76) 在com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest上(JettyServletEngineAdapter.java:135) 位于com.google.apphosting.runtime.JavaRuntime.handleRequest(JavaRuntime.java:235) 在com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest上(RuntimePb.java:5235) 位于com.google.apphosting.base.RuntimePb$EvaluationRuntime$6.handleBlockingRequest(RuntimePb.java:5233) 在com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest(BlockingApplicationHandler.java:24) 位于com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:363) 位于com.google.net.rpc.impl.Server$2.run(Server.java:838) 在com.google.tracing.LocalTraceSpanRunnable.run(LocalTraceSpanRunnable.java:56) 在com.google.tracing.localtracepanbuilder.internalContinueSpan(localtracepanbuilder.java:536) 位于com.google.net.rpc.impl.Server.startRpc(Server.java:793) 位于com.google.net.rpc.impl.Server.processRequest(Server.java:368) 在com.google.net.rpc.impl.ServerConnection.messageReceived上(ServerConnection.java:448) 位于com.google.net.rpc.impl.RpcConnection.parseMessages(RpcConnection.java:319) 位于com.google.net.rpc.impl.RpcConnection.dataReceived(RpcConnection.java:290) 位于com.google.net.async.Connection.handleReadEvent(Connection.java:466) 位于com.google.net.async.EventDispatcher.processNetworkEvents(EventDispatcher.java:759) 位于com.google.net.async.EventDispatcher.internalLoop(EventDispatcher.java:205) 位于com.google.net.async.EventDispatcher.loop(EventDispatcher.java:101) 位于com.google.net.rpc.RpcService.runUntilServerShutdown(RpcService.java:251) 位于com.google.apphosting.runtime.JavaRuntime$RpcRunnable.run(JavaRuntime.java:394) 位于java.lang.Thread.run(未知源) 原因:org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException:执行标记时出错:org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException:执行标记时出错:java.lang.IllegalAccessException:不允许对公共布尔值sun.util.calendar.ZoneInfo.inDaylightTime(java.util.Date)进行反射
这是特定于使用反射在sun上调用方法的动态语言的。*对象由java.util.TimeZone工厂方法返回;我通过在java中编写包装器方法,然后调用该方法,克服了时区中的类似限制,这样sun上的调用。*对象就不会通过反射进行。

以下是我所做工作的Java部分:

package inonit.google.appengine.runtime; import java.util.*; public class Methods { public int getTimezoneOffset(String timezone, long time) { return TimeZone.getTimeZone(timezone).getOffset(time); } } 包inonit.google.appengine.runtime; 导入java.util.*; 公共类方法{ public int getTimezoneOffset(字符串时区,长时间){ 返回时区.getTimeZone(时区).getOffset(时间); } }
我的应用程序不是Grails,我对Grails的了解还不够,不知道Grails定义的抽象是否能使调用类似的类变得容易。但在我的应用程序中,我只是实例化了这个对象的本地助手副本,并在需要计算时区偏移时调用它。

我有一个类似的专业程序当我试图调用TimeZone.getTimeZone()来获取时区,并使用另一个库Joda Time来解决这个问题时出现了问题

这个包中有一些等效的时间/日期方法,它们比底层JDK中的方法工作得更好。

下面的方法对我很有用

public Date getDateWithTimeZone(Date date, String timeZone){
    def tz = TimeZone.getTimeZone(timeZone);
    def cal = Calendar.getInstance()
    cal.setTimeInMillis( date.getTime() )
    cal.setTimeZone( tz )
    def offset = cal.get(Calendar.ZONE_OFFSET)
    date.setTime( date.getTime()+offset )
    return date;
}

目前,我使用一个硬编码的时区列表来解决这个问题。grails timezone标记每次都在所有时区中迭代,这导致执行时间超过了限制,因此必须优化页面。您可能希望将此报告给grails和/或GAE。也许他们会修复它。您能提供一个这种技术的例子?