Beginer help - compiler error

Hi,
I am a beginer to this wonderful framework. I am studing official tutorial, and I am blocked on follow point:

paragraph : 6.2.3 Adding Custom Behaviour

my controller file is follow

package com.company.workshop.web.order;

import com.haulmont.cuba.gui.components.AbstractLookup;

public class OrderBrowse extends AbstractLookup {
   
   @Inject
   private CollectionDatasource<Order, UUID> ordersDs;
   
    public void onBtnNewStatusClick() {
        Order selectedItem = ordersDs.getItem();
        if (selectedItem != null) {
            selectedItem.setStatus(OrderStatus.NEW);
            ordersDs.commit();
        }
    }
}

I receive follow compiler error

Compiler go in error:

        java.lang.RuntimeException: 

com.haulmont.cuba.core.sys.javacl.compiler.CharSequenceCompilerException: Compilation failed. Causes:
OrderBrowse.java:8: error: cannot find symbol
   private CollectionDatasource<Order, UUID> ordersDs;
           ^
  symbol:   class CollectionDatasource
  location: class com.company.workshop.web.order.OrderBrowse OrderBrowse.java:8: error: cannot find symbol
   private CollectionDatasource<Order, UUID> ordersDs;
                                ^
  symbol:   class Order
  location: class com.company.workshop.web.order.OrderBrowse OrderBrowse.java:8: error: cannot find symbol
   private CollectionDatasource<Order, UUID> ordersDs;
                                       ^
  symbol:   class UUID
  location: class com.company.workshop.web.order.OrderBrowse OrderBrowse.java:7: error: cannot find symbol
   @Inject
    ^
  symbol:   class Inject
  location: class com.company.workshop.web.order.OrderBrowse OrderBrowse.java:11: error: cannot find symbol
        Order selectedItem = ordersDs.getItem();
        ^
  symbol:   class Order
  location: class com.company.workshop.web.order.OrderBrowse OrderBrowse.java:13: error: cannot find symbol
            selectedItem.setStatus(OrderStatus.NEW);

I solved looking sample code on github

Hi,

You need to include all required dependencies, for instance:

import com.company.workshop.entity.Order;
import com.company.workshop.entity.OrderStatus;
import com.haulmont.cuba.gui.components.AbstractLookup;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.data.CollectionDatasource;
1 Like

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.

When your code is compiled, the compiler needs to work out what each and every identifier in your code means. As the compiler is going through the code it will find something and know what to do with it or not. Your Cannot find symbol error relates to the identifiers and means that Java cannot figure out what the “symbol” means.

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.