How to enable Weblogic 12.1.2 JPA 2.1

为君一笑 提交于 2019-12-12 12:27:25

问题


I have been deploying our web application to Weblogic server. However, although I was able to deploy the application successfully in this new version, the app does not start up and users cannot login. The log is:

May 29, 2015 4:38:47 PM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)

I believe this happens because Weblogic enables JPA 2.0 by default (but I am not sure of it). Is there a way to enable JPA 2.1?

PS: We are using hibernate 4.3.8 and I am not an expert on application servers.

Regards.


回答1:


If you can upgrade to 12.1.3 then JPA 2.1 support is included but disabled by default, you can follow their instructions for enabling it. It amounts to putting the right jars on the classpath which you can do by adding this to the top of common/bin/commEnv.sh

PRE_CLASSPATH=$MW_HOME/oracle_common/modules/javax.persistence_2.1.jar:$MW_HOME/wlserver/modules/com.oracle.weblogic.jpa21support_1.0.0.0_2-1.jar
export PRE_CLASSPATH


来源:https://stackoverflow.com/questions/30532109/how-to-enable-weblogic-12-1-2-jpa-2-1

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