GWT 应用程序无法从我的 RequestContext 接口找到匹配的方法
你能告诉我我的问题是什么吗?我有 GWT RequestContext ,其中包含一些方法以及一些具有该方法实现的服务类。当我在开发模式下运行时,我的 RequestContext 对象未通过验证。
这是 RequestContext 接口:
@Service(value = CorporateAccountService.class, locator = CorporateAccountServiceLocator.class)
public interface CorporateAccountServiceRequest extends RequestContext {
Request<List<CorporateAccountProxy>> findAllCorporateAccounts();
Request<CorporateAccountProxy> findCorporateAccount(Long id);
InstanceRequest<CorporateAccountProxy, Void> persist();
InstanceRequest<CorporateAccountProxy, Void> remove();
}
这是 ServiceLocator 指定的实现:
public class CorporateAccountService {
public void persist(CorporateAccount corporateAccount) {
EntityManager em = EMF.get().createEntityManager();
try {
em.persist(corporateAccount);
} finally {
em.close();
}
}
public void remove(CorporateAccount corporateAccount) {
EntityManager em = EMF.get().createEntityManager();
try {
CorporateAccount attached = em.find(CorporateAccount.class,
corporateAccount.getId());
em.remove(attached);
} finally {
em.close();
}
}
@SuppressWarnings("unchecked")
public List<CorporateAccount> findAllCorporateAccounts() {
EntityManager em = EMF.get().createEntityManager();
try {
List<CorporateAccount> list = em.createQuery(
"FROM CorporateAccount").getResultList();
// force to get all the employees
list.size();
return list;
} finally {
em.close();
}
}
public CorporateAccount findCorporateAccount(Long id) {
EntityManager em = EMF.get().createEntityManager();
try {
return em.find(CorporateAccount.class, id);
} finally {
em.close();
}
}
}
我收到有关请求上下文验证的错误:
Jun 9, 2011 7:32:10 PM com.dms.admin.shared.CorporateAccountServiceRequest com.google.web.bindery.requestfactory.shared.InstanceRequest remove()
SEVERE: Could not find matching method in com.dms.admin.server.CorporateAccountService.
Possible matches:
void remove(com.dms.admin.server.domain.CorporateAccount )
Jun 9, 2011 7:32:10 PM com.dms.admin.shared.CorporateAccountServiceRequest com.google.web.bindery.requestfactory.shared.InstanceRequest persist()
SEVERE: Could not find matching method in com.dms.admin.server.CorporateAccountService.
Possible matches:
void persist(com.dms.admin.server.domain.CorporateAccount )
Jun 9, 2011 7:32:10 PM com.google.web.bindery.requestfactory.server.ServiceLayerDecorator die
SEVERE: The RequestContext type com.dms.admin.shared.CorporateAccountServiceRequest did not pass validation
Jun 9, 2011 7:32:10 PM com.google.web.bindery.requestfactory.server.RequestFactoryServlet doPost
SEVERE: Unexpected error
com.google.web.bindery.requestfactory.server.UnexpectedException: The RequestContext type com.dms.admin.shared.CorporateAccountServiceRequest did not pass validation
在我的 RequestContext 中定义的 persist(CorporateAccount corpAcc) 和 remove(CorporateAccount corpAcc) 方法存在一些问题,但我正在实施它们。
预先感谢您,非常感谢您的帮助。
Could you tel me please what my problem is? I have GWT RequestContext with some methods in it and some service class with that methods implementation. When I run in Dev mode my RequestContext object doesn't pass validation.
Here is the RequestContext interface:
@Service(value = CorporateAccountService.class, locator = CorporateAccountServiceLocator.class)
public interface CorporateAccountServiceRequest extends RequestContext {
Request<List<CorporateAccountProxy>> findAllCorporateAccounts();
Request<CorporateAccountProxy> findCorporateAccount(Long id);
InstanceRequest<CorporateAccountProxy, Void> persist();
InstanceRequest<CorporateAccountProxy, Void> remove();
}
and here is the implementation specified by the ServiceLocator:
public class CorporateAccountService {
public void persist(CorporateAccount corporateAccount) {
EntityManager em = EMF.get().createEntityManager();
try {
em.persist(corporateAccount);
} finally {
em.close();
}
}
public void remove(CorporateAccount corporateAccount) {
EntityManager em = EMF.get().createEntityManager();
try {
CorporateAccount attached = em.find(CorporateAccount.class,
corporateAccount.getId());
em.remove(attached);
} finally {
em.close();
}
}
@SuppressWarnings("unchecked")
public List<CorporateAccount> findAllCorporateAccounts() {
EntityManager em = EMF.get().createEntityManager();
try {
List<CorporateAccount> list = em.createQuery(
"FROM CorporateAccount").getResultList();
// force to get all the employees
list.size();
return list;
} finally {
em.close();
}
}
public CorporateAccount findCorporateAccount(Long id) {
EntityManager em = EMF.get().createEntityManager();
try {
return em.find(CorporateAccount.class, id);
} finally {
em.close();
}
}
}
I am getting this error about request context validation:
Jun 9, 2011 7:32:10 PM com.dms.admin.shared.CorporateAccountServiceRequest com.google.web.bindery.requestfactory.shared.InstanceRequest remove()
SEVERE: Could not find matching method in com.dms.admin.server.CorporateAccountService.
Possible matches:
void remove(com.dms.admin.server.domain.CorporateAccount )
Jun 9, 2011 7:32:10 PM com.dms.admin.shared.CorporateAccountServiceRequest com.google.web.bindery.requestfactory.shared.InstanceRequest persist()
SEVERE: Could not find matching method in com.dms.admin.server.CorporateAccountService.
Possible matches:
void persist(com.dms.admin.server.domain.CorporateAccount )
Jun 9, 2011 7:32:10 PM com.google.web.bindery.requestfactory.server.ServiceLayerDecorator die
SEVERE: The RequestContext type com.dms.admin.shared.CorporateAccountServiceRequest did not pass validation
Jun 9, 2011 7:32:10 PM com.google.web.bindery.requestfactory.server.RequestFactoryServlet doPost
SEVERE: Unexpected error
com.google.web.bindery.requestfactory.server.UnexpectedException: The RequestContext type com.dms.admin.shared.CorporateAccountServiceRequest did not pass validation
It has some problem with persist(CorporateAccount corpAcc) and remove(CorporateAccount corpAcc) methods defined in my RequestContext but I am implementing them.
Thank you in advance, I appreciate your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该仔细阅读日志,它们的信息非常丰富:
在 CorporateAccountServiceRequest 请求上下文中,您有以下签名:
在 CorporateAccountService 中,您的
方法必须匹配,因为 CorporateAccountServiceRequest 是客户端服务的代理(代表接口)。如果它们不匹配那就不行了。
我想其他日志也和这个一样,所以请继续阅读......
为了纠正它,您应该:
在处理 REquestFactory 时,您还应该检查以下一些规则:
确保您在服务中定义一个名为 findXXX(Long id) 的静态方法,其中 XXX 是您的实体的名称。就你而言,我想它必须像
public static CorporateAccount findCorporateAccount(Long id)
不要失去信心;-)
我希望这有帮助...
You should read the logs carefully, they are pretty informative :
in your CorporateAccountServiceRequest Request Context you have the following signature :
in the CorporateAccountService you have
The methods must match because CorporateAccountServiceRequest is a proxy (a representing interface of) your service on the client Side. If they don't match then it's not ok.
I guess the other logs are also like this one so keep reading...
In order to correct it, you should :
You should also check some of the following rules when dealing with REquestFactory :
Ensure that you define in your service a static method called findXXX(Long id) where XXX is the name of your Entity. In your case, I guess it has to be stg like
public static CorporateAccount findCorporateAccount(Long id)
don't lose faith ;-)
I hope this helped ...