我目前正在尝试使用该SyncProxy
库来测试我的应用程序的服务,以便使用 JMeter 进行负载测试。该应用程序运行良好,我在本地主机上运行它。
当我尝试在我的 JUnit 测试中使用 SyncProxy 时,问题就出现了,它们失败了。
这是 JUnit 测试中使用的一段代码:
ThemeServiceAsync themeServiceAsync = (ThemeServiceAsync) SyncProxy
.newProxyInstance(ThemeServiceAsync.class, MODULE_BASE_URL, GET_THEMES_SERVICE_NAME);
themeServiceAsync.getListTheme(codeEfs, codeSI, noStr, statut, new AsyncCallback<List<Theme>> (){
@Override
public void onFailure(Throwable arg0) {
// TODO Auto-generated method stub
System.out.println(arg0);
}
@Override
public void onSuccess(List<Theme> result) {
// TODO Auto-generated method stub
System.out.println(result);
}
});
我收到以下错误:IOException while receiving RPC response
我使用调试模式来查找问题出在哪里。在服务器端,一切正常,直到结果被发送回客户端。结果在数据库中找到,但我有一个神秘的500错误。
经过挖掘,我发现抛出了这个异常(在AbstractRemoteServiceServlet
):
com.google.gwt.user.client.rpc.SerializationException: Type 'net.gicm.ector.shared.beans.Theme' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.
For security purposes, this type will not be serialized.: instance = net.gicm.ector.shared.beans.Theme@1b7cb71
我发现很多线程都在谈论您的类需要实现“isSerializable”这一事实,但我不明白的是,我实际上是在 localhost 上运行我的应用程序,并且一切正常,包括不同的服务。
但是在运行我的 JUnit 时,我遇到了这些错误。