Message Boards

Liferay 6.2: ClassCastException on portlet re-deploy

Alexey Udalykh, modified 9 Years ago.

Liferay 6.2: ClassCastException on portlet re-deploy

New Member Posts: 3 Join Date: 4/10/14 Recent Posts
Hi,

I have an issue with ClassCastException that happens only after portlet hot re-deploy. The stacktrace itself isn't much of an interest because it's application specific but it boils-down to the following siutation:

- there are two entities (say Student and Course) , described in service.xml and they have many-to-many relationship;
- the code tries to ask for all students enrolled for a specific Course by calling
List<Student> students = courcePersistence.getStudents(courseId);
- what happens then is ClassCastException with the message similar to "StudentImpl can not be cast to Student".

After some investigation I've found out that there are TWO classes of StudentImpl and and TWO classes of Student - they have the same name but they are loaded by different classloaders. The first classLoader seems to be the "new" one (after re-deployment) and the second classLoader seems to be the OLD one that is stuck in JVM even after the portlet re-deploy. Naturally, they load different "versions" of StudentImpl and Student (after and before the redeploy) which causes the issue.

If anyone can give any hint how to overcome this nasty issue - you are more than welcome to share.
Michael Hoos, modified 9 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

New Member Posts: 8 Join Date: 11/14/13 Recent Posts
Hi,

I'm having the same problem. Did you find a solution ?
thumbnail
Punam Shah, modified 9 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

Regular Member Posts: 117 Join Date: 1/20/12 Recent Posts
Hi,

I have face the similar issue in LR6.2; for this workaround, I undeploy and then deploy it again;

Regards,
Punam Shah
Michael Hoos, modified 9 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

New Member Posts: 8 Join Date: 11/14/13 Recent Posts
Undeploy doesn't work for me, I have to restart the server :-(
Viktor Grekov, modified 9 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

New Member Post: 1 Join Date: 10/29/14 Recent Posts
Hi,
I have the same issue. Does anybody have a solution?
thumbnail
Kim Anna Kunc, modified 8 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

Junior Member Posts: 37 Join Date: 2/18/09 Recent Posts
Have a look at this Issue in the Liferay Jira:
https://issues.liferay.com/browse/LPS-46451

Maybe the solution as seen here on Github helps ?
https://github.com/brianchandotcom/liferay-portal/compare/e86917eb8a...dbd6db968c

You would probably have to do this:

(1) In your custom service:
TableMapperFactory.removeTableMapper("...");
and
(2) patch your server to include the other fixes as listed below in the LR classes
ReverseTableMapper, TableMapper, TableMapperFactory & TableMapperImpl
thumbnail
Gautham PJ, modified 8 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

New Member Posts: 4 Join Date: 6/5/13 Recent Posts
To solve the issue temporarily,
  • Undeploy the portlet.
  • Delete the portlet folder from the temp directory.
  • Redeploy the Portlet.

Please check your code to sort this issue properly.
ronak vora, modified 3 Years ago.

Liferay 7.1.3: Issue while using HookPostLogin class loader

Junior Member Posts: 25 Join Date: 9/26/18 Recent Posts
2020-05-04 09:15:47.601 ERROR [http-nio-8080-exec-8][InstancePool:114] Unable to load com.hook.just.JustLoginPostAction with the portal class loader or the current context class loader
java.lang.ClassNotFoundException: com.hook.just.JustLoginPostAction

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1363)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1186)
at com.liferay.portal.kernel.util.InstancePool.get(InstancePool.java:68)
at com.liferay.portal.kernel.util.InstancePool.get(InstancePool.java:33)
at com.liferay.portal.events.EventsProcessorUtil.process(EventsProcessorUtil.java:83)
at com.liferay.portal.events.EventsProcessorUtil.process(EventsProcessorUtil.java:60)
at com.liferay.portal.servlet.MainServlet.loginUser(MainServlet.java:1053)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:517)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Liferay 6.2: ClassCastException on portlet re-deploy

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
Looks like a different issue to me. Could you please open a new thread and give as a bit more information? Like Liferay version, show us the class annotations and maybe any relevant portal-ext properties.