GWT 2.4.0. rc1 Could not find static method with a single parameter of a key type

538 views
Skip to first unread message

Lazo Apostolovski

unread,
Aug 11, 2011, 9:49:05 AM8/11/11
to google-we...@googlegroups.com
Hi all,

I have one entity Device that is stored in database and Two proxies for that entity, one EntityProxy and one ValueProxy.

class Device {
  @Id
  private Long id;

  public Long getId();
  public Integer getVersion();

  public String getMac();
  public void setMac(String mac);
  ....
}

The entity proxy for Device entity is:

@ProxyFor(value = Device.class, locator = DeviceLocator.class)
interface DeviceProxy extends EntityProxy {
  String getMac();

  void setMac(String mac);
  ....
}

The value proxy for Device entity is:

@ProxyFor(Device.class)
public interface DeviceInfoProxy extends ValueProxy {
  String getMac();
  ....
}

I load devices from server with methods:

Request<List<DeviceProxy>> getAllDevices();
Request<DeviceInfoProxy> getDeviceWithMac(String mac);

with version GWT 2.2.0 this works just fine. 
I migrate to version GWT 2.4.0 rc1 and when I try to load devices I receive error:

com.google.web.bindery.requestfactory.server.UnexpectedException: Could not find static method with a single parameter of a key type
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.die(ServiceLayerDecorator.java:216)
at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.getFind(ReflectiveServiceLayer.java:253)
at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.getFind(ReflectiveServiceLayer.java:271)
at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.getFind(ReflectiveServiceLayer.java:271)
at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.isLive(ReflectiveServiceLayer.java:200)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.doIsLive(LocatorServiceLayer.java:186)
at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.isLive(LocatorServiceLayer.java:85)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.createReturnOperations(SimpleRequestProcessor.java:270)
...............
and so on.

So from the stack trace above I understand that for some reason, DeviceLocator for Device entity is not used and Request Factory tries to find static method "findDevice" in Device object, and when that method is not found throw exception.

I debug and notice that in ServiceLayerCache in method getOrCache(), when methodMap is filled, for Device entity create Pair object with Device and BaseProxy, and in the map do not put any locator for Device entity.
So I add DeviceLocator to DeviceInfoProxy (that is ValueProxy).

This fixed the problem, but I do not understand what was the problem? why this fix the problem? and is this the right way to fix the problem?

I do not have problem with another Entity objects or proxies in my project. I just have this problem only for Device entity and Device entity is the only one entity that have Two DTO (EntityProxy/ValueProxy) objects.

Thanks,
Lazo Apostolovski
Reply all
Reply to author
Forward
0 new messages