【问题标题】:How to properly access a File in a gwtp service instance?如何正确访问 gwtp 服务实例中的文件?
【发布时间】:2016-02-15 09:11:45
【问题描述】:

我是 GWT 应用程序的新手,现在正在处理它。我有一个似乎很简单的问题,但我已经好几个小时没有解决它了。我想通过这行代码通过 P12 密钥文件访问谷歌分析数据。

GoogleCredential credential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setServiceAccountId(serviceAccountMail)
    .setServiceAccountPrivateKeyFromP12File(new File("src/main/webapp/WEB-INF/key","XXXXXX-77b2f9138e9612309473.p12"))
    .setServiceAccountScopes(AnalyticsScopes.all()).build();

如果我将上面的代码简单地作为 Java 应用程序运行来测试,代码可以正常工作。但是当我将 GWT 应用程序部署到 tomcat 并让它运行时。我遇到了以下错误。

Mon Feb 15 16:04:41 GMT+800 2016 mp.client.XXAsyncCallback WARNING: 
ERROR:Type 'java.io.FileNotFoundException' was not included in the set of 
types which can be serialized by this SerializationPolicy or its Class    
object could not be loaded. For security purposes, this type will not 
be serialized.
: instance = java.io.FileNotFoundException: XXXXXX-77b2f9138e9612309473.p12
(The system cannot find the file specified) from Service_Proxy.getData

任何即时帮助将不胜感激。谢谢。

【问题讨论】:

    标签: java gwt gwtp


    【解决方案1】:

    GWT 不允许任何类型通过 RPC 传递。 FileNotFoundException 似乎是不应在客户端传递或调用的类型之一。

    可以传递的类类型应该实现接口 com.google.gwt.user.client.rpc.IsSerializable

    更多信息请查看this线程。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2015-02-25
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多