javax.persistence.Table中的NoSuchMethodError [英] NoSuchMethodError in javax.persistence.Table

查看:213
本文介绍了javax.persistence.Table中的NoSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Hibernate 4.3.6,并使用了基于注释的持久性定义.在tomcat 8.0上,它运行良好.但是,当我在WAS Liberty概要文件8.5.5.7中进行部署时,它给出了根本原因,如下所示,并且无法弄清原因.有人告诉将Hibernate升级到5.1.0,但没有用.我正在使用Eclipse进行开发.我也在使用Spring 4.0.1.

I was using Hibernate 4.3.6 and used annotations based persistence definition. On tomcat 8.0 it was working fine. But when I deployed in WAS Liberty profile 8.5.5.7 it gave the root cause exception as below, and haven't been able to figure out why. Some on told to upgrade Hibernate to 5.1.0 but did not work. I am using Eclipse for development. I am also using Spring 4.0.1.

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:824)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3788)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3742)
    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:343)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:431)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:416)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
    ... 57 more

推荐答案

WebSphere Liberty类路径中有不正确的jar,在版本2.1之前带有JPA批注,例如 @NeilStockton建议.

You have an incorrect jar in the WebSphere Liberty class path, with the JPA annotations prior the version 2.1, as @NeilStockton suggested.

首先,尝试在Eclipse的源代码中添加@Table(indexes = {}).如果可以正确导入它-Eclipse的类路径中有正确的hibernate-jpa-2.1-api-1.0.0.Final.jar(用于Hibernate 5).然后删除@Table(indexes = {}).

Firstly, try to add @Table(indexes = {}) whenever in the source in Eclipse. If it can be imported correctly — you have a correct hibernate-jpa-2.1-api-1.0.0.Final.jar (it is for Hibernate 5) in the class path in Eclipse. Delete @Table(indexes = {}) after that.

要查找从中加载了错误的@Table批注的jar,请尝试在独立于Spring配置的某个地方执行此代码.您可以使用ContextListener.

To find a jar from which incorrect @Table annotation is loaded, try to execute this code somewhere independent of the Spring configuration. You can use ContextListener for that.

URL url = Thread.currentThread().getContextClassLoader()
    .getResource("javax/persistence/Table.class");
System.out.println(url);

这篇关于javax.persistence.Table中的NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆