【问题标题】:GWT RPC: using methods of other Service Implementation failsGWT RPC:使用其他服务实现的方法失败
【发布时间】:2016-06-11 18:03:05
【问题描述】:

我在调用我的一项 GWT 服务时遇到错误。

Eclipse 控制台输出如下:

SCHWERWIEGEND: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract de.hdm.gruppe09.clickandlove.shared.report.AllInfosOfProfileReport      de.hdm.gruppe09.clickandlove.shared.ReportGenerator.createAllInfosOfProfileReport(de.hdm.gruppe09.clickandlove.shared.bo.Profil) throws java.lang.IllegalArgumentException' threw an unexpected exception: java.lang.NullPointerException
.......
Caused by: java.lang.NullPointerException
at de.hdm.gruppe09.clickandlove.server.report.ReportGeneratorImpl.createAllInfosOfProfileReport(ReportGeneratorImpl.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 40 more

ReportGeneratorImpl.java:107 看起来像这样(107 是两个 Sysos 中的第一个):

103       //Abrufen des eingeloggten Profils. Wird benoetigt für die anschließende Berechnung des Aehnlichkeitsmaßes
104    Profil ep = this.verwaltung.getEingeloggtesProfil();

//Ausgaben über das ep. Nur zu Textzwecken
107       System.out.println("RGImpl: eingeloggtesProfilID:" + ep.getId());
   System.out.println("RGImpl: eingeloggtesProfilMail:" + ep.getEmail());


//Abrufen des Aehnlichkeitsma�es

int score = this.verwaltung.berechneAhnlichkeit(p, ep);
System.out.println("RGImpl: Score:" + score);
//Score Int Wert in String umwandeln, da new Column nur String Werte annimmt
String scorestring = Integer.toString(score);
//Setzen des Aehnlichkeitsma�es
Row TopRow = new Row();
TopRow.addColumn(new Column(fullname));
TopRow.addColumn(new Column(scorestring));

显然,对象 ep 必须为空。可能是因为第 104 行失败。 每当我使用“this.verwaltung”的方法时,我的方法都会失败。 以下是我创建 verwaltung 对象的方法:

private Verwaltung verwaltung = null;

public void init() throws IllegalArgumentException {
    VerwaltungImpl a = new VerwaltungImpl();
    a.init();
    this.verwaltung = a;
}

由于“ReportGeneratorImpl”和 VerwatlungImpl“都在服务器上运行,我知道我不需要回调来使用彼此的方法。对吗?

【问题讨论】:

  • Christian,您如何登录个人资料? eingeloggtesProfil 何时设置?

标签: java gwt gwt-rpc


【解决方案1】:

显然 Object ep 必须 [原文如此] 为空。

您是否考虑过启动 GWT 与调试器一起使用的嵌入式 Jetty 服务器并在第 104 行设置断点,以便您可以单步执行代码并查看 NullPointerException 的原因是什么?

请参阅开发期间的测试服务了解更多详情:http://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html

【讨论】:

    猜你喜欢
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-24
    • 1970-01-01
    • 2013-03-24
    相关资源
    最近更新 更多