I am creating one example which demonstrates relationship in liferay.I am taking example of Book entity and Author for many to many relationship.I am following below blog fo
I'd expect the involved classes to be twice on the classpath - similar to what David Nebinger answered in this post. Reasons are what he mentions: You might have your xxx-service.jar
on the global classpath as well as in your WEB-INF/lib
, or you might have it on WEB-INF/lib
and added WEB-INF/service
as source folder, so that the same classes are in WEB-INF/classes
again.
Whenever I've seen classloader issues that a class cannot be typecasted to its legitimate superclass or interface, this was an issue of duplicate classes on the classpath. In the ancient past, this also included the ridiculous message that a java object is not a decendant of java.lang.Object - clearly wrong, but it meant the other java.lang.Object that was on the classpath.
The tricky thing is that they need some specific order of instantiation that is not always easy to willingly reproduce. If you found a situation in which you'll always get the message, it will probably always fail the same way. Many-to-many-relationships in Liferay's service-builder might be a way to trigger these problems.