掲示板

Liferay 7 - Export / Import - DLFileEntryImpl cannot be cast to DLFileEntry

thumbnail
7年前 に Benjamin Bini によって更新されました。

Liferay 7 - Export / Import - DLFileEntryImpl cannot be cast to DLFileEntry

Junior Member 投稿: 31 参加年月日: 13/05/24 最新の投稿
Hello,

I am implementing export / import / staging to my application.
In my stagedModelDataHandler, I want to export references to a DLFileEntry. Here is what I do :


StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, stagedModel, stagedModel.getImageId(), PortletDataContext.REFERENCE_TYPE_WEAK);


Where stagedModel.getImageId() returns a DLFileEntry.

The problem is that I got this error when trying to export :

ERROR [liferay/background_task-1][BackgroundTaskMessageListener:164] Unable to execute background task
com.liferay.exportimport.kernel.lar.PortletDataException: java.lang.ClassCastException: com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl cannot be cast to com.liferay.portal.kernel.repository.model.FileEntry


When I look at how export is implemented in Liferay code base, it seems to be done the same way than me.

What can I do to fix it?

Thank you very much!
thumbnail
7年前 に Jorge Díaz によって更新されました。

RE: Liferay 7 - Export / Import - DLFileEntryImpl cannot be cast to DLFileE

Liferay Master 投稿: 753 参加年月日: 14/01/09 最新の投稿
Hi Benjamin,

Please paste the full stacktrace about the "java.lang.ClassCastException"

In some Document Library code the DLFileEntry objects are wrapped inside a com.liferay.portal.kernel.repository.model.FileEntry, perhaps you have to do something related to this.
thumbnail
7年前 に Olaf Kock によって更新されました。

RE: Liferay 7 - Export / Import - DLFileEntryImpl cannot be cast to DLFileE

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Benjamin Bini:
... com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl cannot be cast to com.liferay.portal.kernel.repository.model.FileEntry...


Whenever there's an object that cannot be typecasted to its legitimate supertype, you have a duplicate class (most likely the interface) on your classpath. When there are multiple FileEntry classes loaded, the error message doesn't give an indicator which one is in use and which one is tried for the typecast.
thumbnail
7年前 に Benjamin Bini によって更新されました。

RE: Liferay 7 - Export / Import - DLFileEntryImpl cannot be cast to DLFileE

Junior Member 投稿: 31 参加年月日: 13/05/24 最新の投稿
Thank you. I should have updated the thread: the problem was solved after a server restart. A lot of problems with staging/export/import are actually solved by server restarts. Hot deploy is bad emoticon

Thank you for your answers emoticon