【发布时间】:2014-02-10 20:30:59
【问题描述】:
带有 Spring 4 的 Hibernate 4 webapp。在 Rational Application Developer(IBM 的 eclipse 风格)和 WebSphere 中。我们的应用正在为 spring 和 hibernate 升级。
启动时出现以下异常:
Caused by: java.lang.NoSuchMethodError: javax/persistence/Table.indexes()[Ljavax/persistence/Index;
at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:781)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3762)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:339)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:427)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 77 more
以下信息可能相关,也可能不相关。我觉得是这样的。
不久前,一位同事通过将 hibernate JPA 2.0 api jar 放入我们的 IBM\SDP\runtimes\base_v7\java\jre\lib\ext 文件夹中解决了一个错误。他说这是必要的,因为 RAD 或 WAS 有一个较旧的 JPA,我们需要在它之前加载 2.0。这在当时似乎是一个糟糕的答案,现在我们肯定知道这是因为当我们一次升级我们的应用程序以使用 Hibernate 4 时,我们需要 2.1。但是我们不能在那个文件夹中同时拥有这两个。
那么应该如何处理第二个问题,我想知道人们是否认为这与第一个问题有关,以及如何解决这两个问题。
【问题讨论】: