Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » loader constraint violation
loader constraint violation [message #479287] Mon, 10 August 2009 10:58 Go to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 806
Registered: July 2009
Senior Member
What does this exception mean?


java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "nl/reinders/bm/Batch"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoade r.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301 )
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320 )
at nl.reinders.bm.generated.Article.<clinit>(Article.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.eclipse.persistence.internal.security.PrivilegedAccessHe lper.getClassForName(PrivilegedAccessHelper.java:86)
at org.eclipse.persistence.descriptors.ClassDescriptor.convertC lassNamesToClasses(ClassDescriptor.java:956)
at org.eclipse.persistence.sessions.Project.convertClassNamesTo Classes(Project.java:289)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. deploy(EntityManagerSetupImpl.java:200)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.getServerSession(EntityManagerFactoryImpl.java:69)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManager(EntityManagerFactoryImpl.java:108)
at nl.reinders.bm.BM.createEntityManager(BM.java:97)
at nl.reinders.Reinders$24.actionPerformed(Reinders.java:2855)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButto n.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractB utton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultBu ttonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel .java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.AbstractButton.doClick(AbstractButton.java:337)
at nl.reinders.Reinders.startJpaScreenSwing(Reinders.java:2911)
at nl.reinders.Reinders.access$4(Reinders.java:2797)
at nl.reinders.Reinders$23.run(Reinders.java:2789)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java :199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at org.tbee.swing.EventQueue.dispatchEvent(EventQueue.java:83)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDis patchThread.java:284)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispat chThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDis patchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread. java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread. java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:12 2)
Re: loader constraint violation [message #479723 is a reply to message #479287] Wed, 12 August 2009 03:58 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 806
Registered: July 2009
Senior Member
> java.lang.LinkageError: loader constraint violation: loader (instance of
> sun/misc/Launcher$AppClassLoader) previously initiated loading for a
> different type with name "nl/reinders/bm/Batch"

Ugh. So I have an entity called a "batch" representing an amount of the same article in a certain form. Such a batch has "amount providers", these are entities that either add to or remove an amount from the batch.

These amount providers all implement the BatchAmountProvider interface:

public interface BatchAmountProvider
{
public java.math.BigInteger getAmount() ;
public void setAmount(java.math.BigInteger value);
}


This has worked fine, until I needed to add two methods to the interface allowing me to access the batch they are part of. These methods were already present in all of the implementing classes, I only formalized that by adding them to the interface:

public interface BatchAmountProvider
{
public nl.reinders.bm.Batch getBatch();
public void setBatch(nl.reinders.bm.Batch value);

public java.math.BigInteger getAmount() ;
public void setAmount(java.math.BigInteger value);
}


Either of these two lines are the culprit and cause the loader constraint violation. I still don't understand why.

Tom
Re: loader constraint violation [message #479726 is a reply to message #479723] Wed, 12 August 2009 04:11 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 806
Registered: July 2009
Senior Member
> Either of these two lines are the culprit and cause the loader
> constraint violation. I still don't understand why.

It turns out it is a known bug

https://glassfish.dev.java.net/issues/show_bug.cgi?id=2625

I needed to externalize the interface (it was part of the Batch class) and add it to the persistence.xml.

I did not find an equivalent bug entry in Eclipselink's bugzilla. This is done using Eclipselink 1.1.1.

Tom
Re: loader constraint violation [message #480803 is a reply to message #479726] Tue, 18 August 2009 10:33 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Unusually bug, my guess would be that this is resolved in EclipseLink 2.0,
you may wish to try this. For 1.1, you can add the interface to the
persistence.xml.

---
James


James : Wiki : Book : Blog : Twitter
Previous Topic:EclipseLink - ordering of tables for join statement
Next Topic:Pessimistice locking hint - hanging locks
Goto Forum:
  


Current Time: Fri Apr 18 06:46:57 EDT 2014

Powered by FUDForum. Page generated in 0.01947 seconds