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.
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.