Note that there are some explanatory texts on larger screens.

plurals
  1. POLiferay JPA ClassLoader Error
    primarykey
    data
    text
    <p><strong>EDITED (I'm simplifying as my original question was too convoluted):</strong></p> <p>Create a portlet plugin in Liferay 6.1.20</p> <p>Add in your portlet's web.xml a spring context loader</p> <pre><code>&lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;/WEB-INF/applicationContext.xml&lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; </code></pre> <p>Add in your application context an instance of an EntityManagerFactory</p> <pre><code>&lt;bean id="localEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="persistenceXmlLocation" value="WEB-INF/classes/META-INF/persistence.xml" /&gt; &lt;/bean&gt; </code></pre> <p>Make sure in your persistance definition you're referencing a JPA Implementation</p> <pre><code>&lt;persistence-unit name="casd" transaction-type="RESOURCE_LOCAL"&gt; &lt;provider&gt;org.eclipse.persistence.jpa.PersistenceProvider&lt;/provider&gt; &lt;properties&gt; &lt;property name="eclipselink.weaving" value="false" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>Watch Tomcat cry</p> <pre><code>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 </code></pre> <p>Play with hibernate3.jar, eclipselink.jar, persistence.jar until exhaustion, and realize Liferay is grinning at you.</p> <p>How would you erase that irritating smile from Liferay's face? In other words, </p> <p><strong>How can I get a JPA provider instantiated in a spring context within a portlet plugin in liferay 6.1.20 without getting a classloader error?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload