【发布时间】:2012-06-09 00:21:28
【问题描述】:
我正在尝试使用 JPA 创建一个简单的数据库连接。 它工作正常,但是当我尝试向客户端抛出异常时,我得到了错误:
[ERROR] [browsereditor] - Line 210: No source code is available for type javax.persistence.EntityExistsException; did you forget to inherit a required module?
[ERROR] [browsereditor] - Line 212: No source code is available for type javax.persistence.EntityNotFoundException; did you forget to inherit a required module?
我在开发模式下没有错误,并且编译正常,但是当加载应用程序模块时,我得到了错误。
我在服务器/Composer 和客户端/Presenter 类中有所需的导入
import javax.persistence.EntityExistsException;
import javax.persistence.EntityNotFoundException;
我还在类路径和构建路径中添加了以下 jar:
javax.persistence.jar
jpa-annotations-source.jar (http://code.google.com/p/google-web-toolkit/issues/detail?id=1830#c14)
我也尝试添加到 gwt.xml
<source path='client'/>
<source path='shared'/>
<source path='server'/>
关于如何告诉 eclipse 在哪里找到源代码的任何想法?
谢谢
代码如下:
//从服务器中的Composer.class创建composer
public static Composer createComposer(String name)
throws EntityExistsException {
Composer comp = new Composer();
comp.setName(name);
comp.setId(1);
EntityManager entityManager = entityManager();
entityManager.getTransaction().begin();
entityManager.persist(comp);
entityManager.getTransaction().commit();
entityManager.close();
return comp;
}
///从 Presenter.class 中的 createComposer(above) 触发请求
req.fire(new Receiver<ComposerProxy>() {
public void onSuccess(ComposerProxy arg0) {
ComposerProxy comp;
comp = arg0;
}
public void onFailure(Throwable caught)
throws Throwable {
// Convenient way to find out which exception
// was thrown.
try {
throw caught;
} catch (EntityExistsException e) {
} catch (EntityNotFoundException e) {
}
}});
}});
[ERROR] [browsereditor] - Line 210: No source code is available for type javax.persistence.EntityExistsException; did you forget to inherit a required module?
[ERROR] [browsereditor] - Line 212: No source code is available for type javax.persistence.EntityNotFoundException; did you forget to inherit a required module?
【问题讨论】:
标签: gwt jpa persistence requestfactory