liferay服务构建器中的异常“:”java.lang.ClassCastException [英] exception":"java.lang.ClassCastException in liferay service builder

查看:130
本文介绍了liferay服务构建器中的异常“:”java.lang.ClassCastException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在实施Entity远程服务。
我在EntityServiceImpl中创建了一个自定义服务方法,创建了通过InstitutionServiceUtil提供服务的自定义服务方法。
在部署portlet之后,在从浏览器窗口发送请求到服务方法时,我收到以下异常

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.

如何解决上面的例外?

推荐答案

我假设 InstitutionImpl 实现了接口机构。如果是这样,那么异常的根本原因是类加载:类加载器A加载了机构,但 InstitutionImpl 是从一个加载的不同的类加载器。如果完全限定名称类加载器相同,则Java中的两个类只相同。

I assuming that InstitutionImpl implements the interface Institution. If so, then the root cause of the exception is classloading: Classloader A did load Institution but InstitutionImpl was loaded from a different classloader. Two classes in Java are only equivalent if the fully qualified name and the classloader are the same.

我对liferay的了解不够告诉你它是如何加载类的。但是要解决这个问题,你需要找出当你尝试加载你的实现时可能已经存在 Institution 接口(可能来自之前的部署尝试)。

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

这篇关于liferay服务构建器中的异常“:”java.lang.ClassCastException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆