私たちのアプリケーションでは、GWTクライアントとサーバーの間でドメインコードを共有する必要があります。そのため、GWTプロキシとサーバー側エンティティに共通のインターフェイスを使用しています。このアプローチは、かつてここでは、@トーマス・broyerによって記述された:https://stackoverflow.com/a/15852887/187241GWT RequestFactoryがjava.lang.UnsupportedOperationExceptionをスローする:<Proxy interface class> from ValueCodex.getTypeOrDie
例外スタックトレース:
ERROR com.google.web.bindery.requestfactory.server.SimpleRequestProcessor - Error while processing request
java.lang.UnsupportedOperationException: se.homework.hwbs.domain.shared.model.IAppointment
at com.google.web.bindery.autobean.shared.ValueCodex.getTypeOrDie(ValueCodex.java:388)
at com.google.web.bindery.autobean.shared.ValueCodex.decode(ValueCodex.java:312)
at com.google.web.bindery.requestfactory.shared.impl.EntityCodex.decode(EntityCodex.java:107)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor$3.visitReferenceProperty(SimpleRequestProcessor.java:633)
at com.google.web.bindery.autobean.vm.impl.ProxyAutoBean.traverseProperties(ProxyAutoBean.java:370)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:162)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:97)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processOperationMessages(SimpleRequestProcessor.java:623)
共有コード:
public interface IAppointment {
IPlace getPlace();
}
public interface AppointmentProxy extends EntityProxy, IAppointment {
@Override
PlaceProxy getPlace();
}
public interface PlaceProxy extends EntityProxy, IPlace {
@Override
Long getId();
}
public interface IPlace extends IDatabaseEntity {
@Override
Long getId();
}
public interface IDatabaseEntity {
public Long getId();
}
私たちは、正確な理由をGWTコードをundersttod場合問題の原因は、ProxyAutoBean
:
beanType
はAppointmentProxy.class
です。
public **abstract** PlaceProxy AppointmentProxy.getPlace()
public **default** IPlace AppointmentProxy.getPlace()
最初のものが期待とGWT RequestFactoryコードによって受け入れられ、第二の一方はない...そして:Javaリフレクションは、インターフェイスするための2つの方法(のみスーパーDevのモードで行わ...)を返しますjava.lang.UnsupportedOperationException: IAppointment
例外が発生します。非常に奇妙な事実は、コンパイルされたGWTアプリケーションでのみこの問題が発生しているということです。スーパーデベロッパーモードを使用してIDEからアプリケーションを起動すると、2番目のdefault ...
メソッドは表示されず、アプリケーションはエラーなく動作します。
環境:
- GWT 2.6 0.1
- Javaバージョン1.8.0_66
あなたが修正したり、問題を回避する方法についてのアイデアを持っていますか?
新しいバージョンのGWTを試しましたか? 2.6はほぼ2歳で、2.7で多くのバグが修正されました(2.8にすぐに入ろうとしています)。 –
はい、GWT 2.6です。時代遅れで、2.7を飛ばして、一度に2.8までアップグレードする予定でした。しかし、2.8ベータ版ではGitHubで報告されているいくつかの問題に直面していますが、まだ修正されていません。 Thomas Broyerの答えを考慮に入れて、2.7をスキップするのは悪い考えでした。 – ilya