RequestFactory with Use of Locator

148 views
Skip to first unread message

hkropp

unread,
Nov 7, 2011, 8:36:59 AM11/7/11
to google-we...@googlegroups.com
Hi,
sorry I have to ask, but the example at http://code.google.com/intl/en-US/webtoolkit/doc/latest/DevGuideRequestFactory.html is relative unclear to me how about making the RequestFactory work with Persistence function NOT in the Entity and not beeing static. I have not found any examples. Could some one please help.

I am experience the following problem/exception with my implementation and can see were the problem is:

@Service(value = EmployeeService.class, locator = DaoServiceLocator.class)
public interface EmployeeRequest extends RequestContext {
...
InstanceRequest<EmployeeProxy, Void> persist(EmployeeProxy employee);
}

ServiceImpl:
public class EmployeeService extends GenericDAO<EmployeeGWT, ObjectId>{
...
public void persist(EmployeeGWT employee){
    em.save(employee);
}
}

Client call:
EmployeeRequest request = requestFactory.employeeRequest();
EmployeeProxy newEmployee = request.create(EmployeeProxy.class);

newEmployee.setDepartment("void");
newEmployee.setDisplayName("VoidMan");

Request<Void> createReq = request.persist(newEmployee).using(newEmployee);

I get the following Exception:
java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.invoke(ReflectiveServiceLayer.java:182)

I am not sure what this means and looking for clues. Is the @Service wrong or what is missing or wrong here? Maybe this is even totally unrelated to my question?

kind regards

Patrick Julien

unread,
Nov 7, 2011, 9:23:36 AM11/7/11
to google-we...@googlegroups.com
If you use InstanceRequest, that means the method you're calling must be non-static, which is what you want here but also be of your entity type.  Here

@Service(value = EmployeeService.class, locator = DaoServiceLocator.class)
public interface EmployeeRequest extends RequestContext {
...
 Request<Void> persist(EmployeeProxy employee);

with your EmployeeService should do it.  InstanceRequest is for calling a method of EmployeeGWT in this case

will do it.

However, you need to use fire, not using
Request<Void> createReq = request.persist(newEmployee).fire(new Receiver<Void>() { ...

hkropp

unread,
Nov 8, 2011, 4:15:09 AM11/8/11
to google-we...@googlegroups.com
Thank you!
It worked, although now I have a java.lang.IllegalArgumentException: argument type mismatch to figure out, which probably is related to the Proxy/Entity.

MagusDrk

unread,
Feb 3, 2012, 3:18:58 PM2/3/12
to google-we...@googlegroups.com
Hi hkopp Right now I'm facing the argument type mismatch error, but i'm unable to find the cause. I guess you were able to do it since there were no more comments. How did you found the cause? how did you solved? thanks a lot.
Reply all
Reply to author
Forward
0 new messages