Foros de discusión

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

thumbnail
Benjamin Bini, modificado hace 7 años.

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

Junior Member Mensajes: 31 Fecha de incorporación: 24/05/13 Mensajes recientes
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
Jorge Díaz, modificado hace 7 años.

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

Liferay Master Mensajes: 753 Fecha de incorporación: 9/01/14 Mensajes recientes
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
Olaf Kock, modificado hace 7 años.

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

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
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
Benjamin Bini, modificado hace 7 años.

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

Junior Member Mensajes: 31 Fecha de incorporación: 24/05/13 Mensajes recientes
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