Extended FileDescriptor entity causing Conversion Exception


I have created a new entity CustomFileDescriptor which has its parent class set to sys$filedescriptor.

I have then created another entity CustomFilesTest that has a one-to-one composition column to the CustomFileDescriptor entity.

I created standard browse and edit screens for a view on CustomFilesTest.

When I try to upload a file I get the following error.

I do have a custom FileStorageAPI implementation based on the AWS code in CUBA. This has been working fine on standard FileDescriptors and appears to be working now and the error comes after uploading the file actually happens.

I’m basically trying to see if there is a way to get additional data to the FileStorageAPI implementation via a CustomFileDescriptor but I may be on the wrong track.

Perhaps DynamicAttributes might be an option.

Does anyone know why I’m getting the error?

com.vaadin.data.util.converter.Converter$ConversionException: Unable to convert value of type com.haulmont.cuba.core.entity.FileDescriptor to model type class com.company.filecloudpoc.entity.CustomFileDescriptor. No converter is set and the types are not compatible.
	at com.vaadin.data.util.converter.ConverterUtil.convertToModel(ConverterUtil.java:180)
	at com.vaadin.ui.AbstractField.convertToModel(AbstractField.java:810)
	at com.vaadin.ui.AbstractField.convertToModel(AbstractField.java:790)
	at com.vaadin.ui.AbstractField.setValue(AbstractField.java:564)
	at com.vaadin.ui.AbstractField.setValueIgnoreReadOnly(AbstractField.java:479)
	at com.haulmont.cuba.web.gui.components.WebAbstractField.setValue(WebAbstractField.java:244)
	at com.haulmont.cuba.web.gui.components.WebFileUploadField.saveFile(WebFileUploadField.java:155)
	at com.haulmont.cuba.web.gui.components.WebFileUploadField.lambda$initUploadButton$982e378a$1(WebFileUploadField.java:275)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163)
	at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037)
	at com.haulmont.cuba.web.toolkit.ui.CubaFileUpload.fireUploadSuccess(CubaFileUpload.java:484)
	at com.haulmont.cuba.web.toolkit.ui.CubaFileUpload$1.fileUploaded(CubaFileUpload.java:72)


Do you use Replace parent option for CustomFileDescriptor entity?

Hi @artamonov

Thanks for pointing that out. That was indeed what was missing.

Now that I have it running I do see my CustomFileDescriptor coming through to my custom FileStorageAPI. There is a problem in that I don’t know how to set a field in the CustomFileDescriptor.

In the screen the UI only shows the FileUpload for the whole CustomFileDescriptor datasource.

I tried adding a field to show my property from the CustomFileDescriptor which it does and I can enter text in there but as soon as I click the upload button it appears to create a new CustomFileDescriptor instance and so the additional property I have in the CustomFileDescriptor is set to null and is never set when it get to the FileStorageAPI.

Is there a way of either setting the custom property in code or via the screen UI so that the value gets to the FileStorageAPI?

I’ve managed to get the data through by doing a manual upload and coding what I need in the uploadField.addFileUploadSucceedListener