openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeremy Bauer (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1410) Class linkage exception when creating an EMF with OpenJPA M3
Date Wed, 17 Mar 2010 20:17:27 GMT


Jeremy Bauer commented on OPENJPA-1410:

I committed a change under rev 924395 that disables the dynamic enhancer if the OpenJPA instrumentation
factory is not loaded by the system classloader.  In a multi-tier classloader environment
(Tomcat, JEE app server, etc.)  the OpenJPA jar was being loaded by the container classloader
and then loaded a second time into the system classloader (as an agent).  This lead to linkage
issues since OpenJPA classes were loaded from multiple loaders and there ended up being a
mix of classes in the execution path.  

After correcting this issue, the subclassing enhancer is working again (but that has its own
set of deficiencies and is not recommended) - but agent-based enhancement (-javaagent:...)
is not.  This is not a result of my change, there is some other issue.  I plan on looking
into that next.

As of rev 924395 the openjpa.DynamicEnhancementAgent=false property should no longer be required,
but build time enhancement of entities may still be necessary.

> Class linkage exception when creating an EMF with OpenJPA M3
> ------------------------------------------------------------
>                 Key: OPENJPA-1410
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: validation
>    Affects Versions: 2.0.0-M3, 2.0.0-beta, 2.0.0-beta2
>         Environment: Tomcat and Glassfish, OpenJPA M3
>            Reporter: Jeremy Bauer
>            Assignee: Jeremy Bauer
>            Priority: Critical
>             Fix For: 2.0.0
> Posted by Seth Jackson on the user forum[1].
> It appears something was modified in OpenJPA 2.0 M3 from M2 that causes a
> LinkageError.
> In my current environment, I've tested both Glassfish and Tomcat using M2
> and M3. M2 runs without problems, but M3 throws a linkage error as follows:
> Caused by: java.lang.LinkageError: loader constraint violation: loader
> (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading
> for a different type with name
> "org/apache/openjpa/conf/OpenJPAConfiguration"
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(
>        at
>        at
>        at$000(
>        at$
>        at Method)
>        at
>        at java.lang.ClassLoader.loadClass(
>        at sun.misc.Launcher$AppClassLoader.loadClass(
>        at java.lang.ClassLoader.loadClass(
>        at java.lang.ClassLoader.loadClassInternal(
>        at
> org.apache.openjpa.persistence.validation.ValidationUtils.setupValidation(
>        at
> org.apache.openjpa.persistence.PersistenceProviderImpl.loadValidator(
>        at
> org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(
>        at
> org.apache.openjpa.persistence.OpenJPAPersistence.createEntityManagerFactory(
>        at
> org.apache.openjpa.persistence.OpenJPAPersistence.createEntityManagerFactory(
>        at test_test.user.UserAction.execute(
> I've already confirmed that the OpenJPA classes in question do NOT exist in
> any other JARs in the path.
> ValidationUtils.setupValidation( calls the
> OpenJPAConfiguration.getConfigurationLog(). The object being referenced is
> JDBCConfigurationImpl, which in other classes retrieves the log reference
> perfectly fine, before it gets to the offending line.
> Seth's follow up[2]:
> After further review, using Glassfish 2.1.1 I received this error message in
> the server log:
> Caused by: java.lang.LinkageError: loader constraint violation: when
> resolving method
> "org.apache.openjpa.persistence.validation.ValidationUtils.setupValidation(Lorg/apache/openjpa/conf/OpenJPAConfiguration;)Z"
> the class loader (instance of org/apache/catalina/loader/WebappClassLoader)
> of the current class,
> org/apache/openjpa/persistence/PersistenceProviderImpl, and the class loader
> (instance of sun/misc/Launcher$AppClassLoader) for resolved class,
> org/apache/openjpa/persistence/validation/ValidationUtils, have different
> Class objects for the type org/apache/openjpa/conf/OpenJPAConfiguration used
> in the signature
> So it appears to be the WebappClassLoader and the AppClassLoader are both
> loading the OpenJPAConfiguration from the same JAR file, causing the error
> when the class is trying to be resolved in this particular method.
> [1]
> [2]

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message