Tomcat but not Jetty: NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey

﹥>﹥吖頭↗ 提交于 2019-12-25 12:51:28

问题


I have recently upgraded my Wicket 6 application from Spring 3 to Spring 4.

When I run the application locally on Jetty 7, it runs fine.

When I deploy it to Tomcat 7, I get the following error:

[2014-05-07 10:20:47,121] ERROR [org.springframework.web.context.ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;

Is this a Tomcat issue or should I just go ahead and try to solve the nested exception java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()?

If the issue is indeed with the foreignKey, then why does the problem not occur on Jetty?

spring.version 4.0.4.RELEASE

hibernate.version 4.3.5.Final

dataSource: class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"


回答1:


nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey

This exception occurs of there are conflicting version of javax.persistence.ForeignKey class. Check your classpath and if you are using maven check the dependencies.




回答2:


For me, issue fixed after downgrading my project to java 6 and hibernate-entitymanager version to 3.6.9.FINAL



来源:https://stackoverflow.com/questions/23513830/tomcat-but-not-jetty-nosuchmethoderror-javax-persistence-joincolumn-foreignkey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!