代码之家  ›  专栏  ›  技术社区  ›  Iam Riz

如何正确访问gwtp服务实例中的文件?

  •  0
  • Iam Riz  · 技术社区  · 10 年前

    我是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
    

    任何立即的帮助都将不胜感激。谢谢

    1 回复  |  直到 10 年前
        1
  •  2
  •   Community Mohan Dere    9 年前

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

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

    有关更多信息,请查看 this 线

    希望这有帮助。

    推荐文章