【问题标题】:Hibernate exception JPA休眠异常 JPA
【发布时间】: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。但是我们不能在那个文件夹中同时拥有这两个。

那么应该如何处理第二个问题,我想知道人们是否认为这与第一个问题有关,以及如何解决这两个问题。

【问题讨论】:

    标签: hibernate jpa websphere


    【解决方案1】:

    JPA 库可能会放在WEB-INF\libs webapp 目录中。 但是对于 WebSphere Application Server 存在特殊的 JPA2 功能包:WebSphere Application Server V7 Feature Pack for OSGi Applications and Java Persistence API 2.0

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 1970-01-01
      • 2011-02-14
      • 1970-01-01
      • 2014-08-22
      • 2011-09-20
      • 2017-07-06
      • 2012-02-24
      • 1970-01-01
      相关资源
      最近更新 更多