I have worked on implementation of the Entity remote service. I have created one custom service method in EntityServiceImpl,Created custom service method providing service through InstitutionServiceUtil. After deploy the portlet, while sending request to service method through from browser window,I am getting below Exception
exception":"java.lang.ClassCastException: com.institutions.model.impl.InstitutionImpl
cannot be cast to com.institutions.model.Institution
Note: If I send the request after restart the server, I didn't get above exception.
How to resolve the above Exception?
I assuming that
InstitutionImpl
implements the interfaceInstitution
. If so, then the root cause of the exception is classloading: Classloader A did loadInstitution
butInstitutionImpl
was loaded from a different classloader. Two classes in Java are only equivalent if the fully qualified name and the classloader are the same.I don't know enough about liferay to tell you how it's class loading works. But to solve the problem, you need to find out if the
Institution
interface could already be around when you try to load your implementation (maybe from a previous deployment attempt).