我正在尝试使用 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?
我在开发模式下没有错误,它编译得很好,但是当应用程序模块被加载时,我得到了错误。
我在 server/Composer 和 client/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 创建作曲家
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?