LinkageError loader constraints violated problem solved

K

KanZen

Recently I had a problem with a java.lang.LinkageError being thrown with the
message: Loader constraints violated. This is happening when a call is made
to an EJB with SunOne App Server 7. After searching around I found that a few
other people had hit a similar problem, but nobody seemed to have posted a
solution.

I found that the problem was a call from a Servlet like this:

RemoteInterface remoteInterface = home.create();
ValueObject valueObject = remoteInterface.someMethod();

The problem was that the ValueObject class was packaged in both the foo.war and
the foo-ejb.jar files, and the Servlet container and EJB container were in the
same JVM. Removing the ValueObject (and RemoteInterface) class from the foo.war
solved the problem, as then the EJB class loader was used exclusively.

This is doubtless a well known issue, but it's still awkward the first time you
bump into it. Normally we are used to having a ClassCastException thrown in this
sort of situation, but here the class is being loaded for the first time, as
opposed to when an existing object is cast to an Interface of a diferent class
loader.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top