Liferay JPA ClassLoader错误

时间:2012-08-29 09:27:43

标签: jpa integration liferay

已编辑(我正在简化,因为我原来的问题太复杂了):

在Liferay 6.1.20中创建一个portlet插件

在portlet的web.xml中添加一个spring上下文加载器

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

在您的应用程序上下文中添加EntityManagerFactory

的实例
<bean id="localEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation" value="WEB-INF/classes/META-INF/persistence.xml" />
</bean>

确保您的持久定义中引用了JPA实现

<persistence-unit name="casd" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <properties>
        <property name="eclipselink.weaving" value="false" />
    </properties>
</persistence-unit>

观看Tomcat哭泣

java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.eclipse.persistence.jpa.PersistenceProvider.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/eclipse/persistence/jpa/PersistenceProvider, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for interface javax/persistence/spi/PersistenceProvider have different Class objects for the type javax/persistence/spi/ProviderUtil used in the signature

玩hibernate3.jar,eclipselink.jar,persistence.jar直到筋疲力尽,并意识到Liferay正在咧嘴笑着。

你怎么会抹去Liferay脸上那刺激的微笑? 换句话说,

如何在liferay 6.1.20中的portlet插件中的spring上下文中实例化JPA提供程序,而不会出现类加载器错误?

1 个答案:

答案 0 :(得分:0)

确定。我设法“解决”将ecliseplink.jar从/ ROOT / WEB-INF / lib移动到{tomcat} / lib / ext

的问题

我不喜欢它作为一个解决方案,不得不捣乱分机,但这是一个接受或留下它的情况。