FileUpload Errors

Sorry I know this seems to be a recurring question on the Forum. I have tried all the examples (straight copy and pastes from the manual as well) and I have copied responses in the Forum, however I get the same error no matter where I try it from. I have tried various screen types, etc.


 private FileUploadField uploadField; 

java:10: error: cannot find symbol

Same error under the FileUploadAPI.

I have attempted to put use it on different screens with corresponding Controller code but the error always comes back to the file upload Component.

Version 6.6.2 (with Premium). The External File Upload under Administration does work, so this is why I find it so baffling. Any assistance is appreciated.


entire error message below
studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:10: error: cannot find symbol
    private FileUploadField uploadField;
            ^
  symbol:   class FileUploadField
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:12: error: cannot find symbol
    private FileUploadingAPI fileUploadingAPI;
            ^
  symbol:   class FileUploadingAPI
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:15: error: cannot find symbol
    public void init(Map<String, Object> params) {
                     ^
  symbol:   class Map
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:30: error: cannot find symbol
    private void processFile(File file) {
                             ^
  symbol:   class File
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:9: error: cannot find symbol
@Inject
 ^
  symbol:   class Inject
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:11: error: cannot find symbol
    @Inject
     ^
  symbol:   class Inject
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:17: error: cannot find symbol
            UUID fileId = uploadField.getFileId();
            ^
  symbol:   class UUID
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:18: error: cannot find symbol
            File file = fileUploadingAPI.getFile(fileId);
            ^
  symbol:   class File
  location: class LocalFilesEdit
/home/ftadmin/studio-projects/A1/modules/web/src/com/company/a1/web/localfiles/LocalFilesEdit.java:24: error: cannot find symbol
            } catch (FileStorageException ex) {
                     ^
  symbol:   class FileStorageException
  location: class LocalFilesEdit

Hi,
please, open your screen in Idea and check, that you add all the imports. Use the ALT+Enter shortcut to import all necessary files.


import com.haulmont.cuba.core.entity.FileDescriptor;
import com.haulmont.cuba.core.global.FileStorageException;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.company.fileuploadtest.entity.FileEntity;
import com.haulmont.cuba.gui.components.FileUploadField;
import com.haulmont.cuba.gui.data.DataSupplier;
import com.haulmont.cuba.gui.upload.FileUploadingAPI;

import javax.inject.Inject;
import java.util.Map;

We strongly recommend editing screen controllers code using Idea.

Natalie.
Spot on. I had expected that Cuba would add in the imports, so I had not looked at this in the IDE (IntelliJ).

Greg

The “Cannot find symbol” errors generally occur when you try to reference an undeclared variable in your code. A “Cannot find symbol” error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn’t understand.

The general causes for a Cannot find symbol error are things like:

  • Incorrect spelling.

  • Wrong case. Halo is different from halo.

  • Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.

  • No variable declaration or variable is outside of the scope you are referencing it in.