Liferay Many-to-Many RelationShip Throws Class Cast Exception

前端 未结 1 1346
夕颜
夕颜 2021-01-17 03:06

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

相关标签:
1条回答
  • 2021-01-17 04:11

    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.

    0 讨论(0)
提交回复
热议问题