我正在尝试使用GWT RF取回数据,但我遇到了一些麻烦。 这是我的工厂,代理和实体。
server.domain包下的实体:
public class Job implements Serializable {
private int id;
private String announcer;
private String applied;
private String date;
private String description;
private String email;
private String title;
private int version;
static SessionFactory factory;
static ServiceRegistry serviceRegistry;
public Job() {
try {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(
configuration.getProperties()).buildServiceRegistry();
factory = configuration.buildSessionFactory(serviceRegistry);
}catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);
}
}
//Setters&Getters
public void persist() {
Session session = factory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
Job job = this;
session.save(job);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
e.printStackTrace();
} finally {
session.close();
}
}
public static List<Job> findAllJobs() {
Session session = factory.openSession();
Transaction tx = null;
List<Job> list = null;
try {
tx = session.beginTransaction();
Query query = session.createQuery("select * from Job");
list = query.list();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
e.printStackTrace();
} finally {
session.close();
}
return list;
}
JobRequest类文件包含:
Request<List<JobProxy>> findAllJobs();
入门单元:
final EventBus eventBus = new SimpleEventBus();
JobRequestFactory requestFactory = GWT.create(JobRequestFactory.class);
requestFactory.initialize(eventBus);
JobRequest request = requestFactory.jobRequest();
JobProxy newJob = request.create(JobProxy.class);
requestFactory.jobRequest().findAllJobs().to(new Receiver<List<JobProxy>>(){
public void onSuccess(List<JobProxy> jobs)
{
System.out.println("SIZE:"+jobs.size());
}
}).fire();
最后我的错误是:
com.google.web.bindery.requestfactory.server.ServiceLayerDecorator die
SEVERE: No RequestContext for operation Lk3VEjMsjGdUyVzlgtz$ggTrjMA=
我无法弄清楚为什么会发生这种情况......
答案 0 :(得分:0)
这通常意味着ValidationTool(或注释处理器)未使用JobRequestFactory
的最新版本运行,尤其是在JobRequest
没有JobRequestFactory
时运行它存在,JobRequest
没有方法返回findAllJobs
,或{{1}}不存在或具有不同的签名(例如,参数)。