0

我使用 Elastic Beanstalk 实现了一个应用程序。由于某些类将被持久化,因此我将(Apache 的)JDO 注释与 DataNucleus 结合使用。

在本地服务器上运行应用程序时一切正常,这意味着我可以将普通的旧 Java 对象保存到连接的 Amazon RDS。将同一应用程序部署到 Elastic Beanstalk 时,我收到以下错误消息:

org.datanucleus.api.jdo.exceptions.ClassNotPersistenceCapableException: The class "edu.kit.aifb.cloudcampus.dom.mgmt.Dozent" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
NestedThrowables:
org.datanucleus.exceptions.ClassNotPersistableException: The class "edu.kit.aifb.cloudcampus.dom.mgmt.Dozent" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.

org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:380)
    org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:731)
    org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:751)

我想知道为什么会这样,因为我已经使用以下代码行以编程方式增强了我的类

public void enhanceJDOClasses(String...clazzes) {
    JDOHelper.getEnhancer().addClasses(clazzes).enhance();
}

有没有推荐的方法以另一种方式处理这个问题,或者是否有人遇到过类似的异常?任何帮助表示赞赏。

4

1 回答 1

0

所以增强版的类不在当前的classLoader中。该命令并没有把它放在那里,只是增强了类,一旦一个类(未增强的)被加载到 ClassLoader 中,它就不能被替换。但是,您可以将 classLoader 设置为增强器

于 2013-05-03T18:30:33.797 回答