2013-05-03 97 views
0

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

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

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) 

我想知道为什么发生这种情况,因为我已经programmaticaly提高了我的教学班的代码下面几行

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

有任何推荐的方式来处理这个以另一种方式或任何人遇到类似的例外?任何帮助表示赞赏。

回答

0

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

+0

啊,好的。所以你的意思是 'public void enhanceJDOClasses(String ... clazzes){ \t \t ClassLoader contextClassLoader = Thread.currentThread()。getContextClassLoader(); \t \t JDOHelper.getEnhancer(contextClassLoader).addClasses(clazzes).enhance(); \t}' 会解决这个问题吗?我会试一试。谢谢你的答案。 – Bugra 2013-05-06 08:09:22

+0

这样做。现在我还有其他例外。但是这解决了第一个问题。谢谢。 – Bugra 2013-05-06 09:11:45